Midterm_signal_processing/Signalanalysis.m

45 lines
897 B
Matlab

clear all
close all
clc
pkg load signal
% Read the csv file
signal = csvread('unknownsignal.csv');
Fs = 300; % Sampling frequency
t = (0:length(signal)-1)/Fs;
N = length(signal);
duration = N / Fs;
% Plot the time-domain signal
figure;
plot(t, signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Time-Domain Signal');
window = hann(N)';
windowed_data = window .* signal;
a=size(windowed_data);
display(a);
% Perform spectral analysis using the spectrogram with specified parameters:
[power,duration]=frequencySpectrum(signal, Fs, false);
% Calculate the spectrogram
% Design a Butterworth bandpass filter
[b,a] = butter(3,0.4);
y = filter(b, a, windowed_data);
% Apply the filter to the signal
spectrogram(y,Fs,5,30);
% Visualize the filtered signal in the time domain:
figure;
plot(t, filtered_signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Filtered Signal (30-40 Hz)');