Ajouter 'signal_analysis.m'
This commit is contained in:
parent
5776ab5811
commit
a1062222df
|
|
@ -0,0 +1,59 @@
|
|||
pkg load signal
|
||||
|
||||
file_path = 'part1.wav';
|
||||
|
||||
[x, Fs] = audioread(file_path);
|
||||
|
||||
t = (0:length(x)-1) / Fs;
|
||||
|
||||
|
||||
|
||||
subplot(2,2,1);
|
||||
plot(t, x);
|
||||
title('Time Domain - Original Signal');
|
||||
xlabel('Time (s)');
|
||||
ylabel('Amplitude');
|
||||
|
||||
window = blackman(length(t));
|
||||
windowed_part = x .* window;
|
||||
|
||||
subplot(2,2,2);
|
||||
plot(t, windowed_part)
|
||||
xlabel('Time (s)')
|
||||
ylabel('Amplitude')
|
||||
title('Blackman Window Applied')
|
||||
|
||||
|
||||
Nfir = 5;
|
||||
cutOffFrequency = 50;
|
||||
|
||||
[B, A] = butter(Nfir, cutOffFrequency/(Fs/2));
|
||||
|
||||
filteredSignal = filter(B, A, windowed_cosine);
|
||||
|
||||
|
||||
|
||||
subplot(2,2,3);
|
||||
plot(t, filteredSignal);
|
||||
xlabel('time (s)');
|
||||
ylabel('amplitude (a.u.)');
|
||||
title('IIR-Filtered signal')
|
||||
|
||||
X = fft(filteredSignal); % Compute FFT
|
||||
freq = (0:N-1) * (Fs/N); % Frequency axis
|
||||
|
||||
subplot(2,2,4);
|
||||
stem(freq, abs(X));
|
||||
title('Filtered Signal (Frequency Domain)');
|
||||
xlabel('Frequency (Hz)');
|
||||
ylabel('Magnitude');
|
||||
|
||||
Z=roots(B);
|
||||
P=roots(A);
|
||||
figure
|
||||
zplane(Z,P);
|
||||
title ('Zeros and poles of the transsamplingFreqr function');
|
||||
legend('zeros','poles');
|
||||
grid on;
|
||||
|
||||
frequencySpectrum(filteredSignal,Fs);
|
||||
Loading…
Reference in New Issue