Professional Documents
Culture Documents
EE-20141
LAB SESSION 6
To observe/find different frequency components in an audio signal and plot it with different x-
axes.
clear all; clc; close all;
[y,Fs] = audioread('noisy.wav');
Ts = 1/Fs; n = [0:length(y)-1];
t = n.*Ts; k = n;
Df = Fs./length(y);
F = k.*Df; Y = fft(y);
magY = abs(Y);
sound(y,Fs);
figure,
subplot(2,1,1);
plot(F,magY); grid on;
xlim([0 Fs/2]);
xlabel('Frequency (Hz)'); ylabel('DFT Magnitude');
title('Discrete Fourier Transform');
subplot(2,1,2);
plot(F,magY); grid on;
xlim([0 2000]);
xlabel('Frequency (Hz)'); ylabel('DFT Magnitude');
title('Discrete Fourier Transform');
TASK#1:
clc,clear,close all
sound(y,Fs); pause(3);
subplot(3,1,1);
plot(t,y); xlim([0 2]);
subplot(3,1,2);
plot(F,magY); grid on; xlim([0 Fs/2]);
xlabel('Frequency (Hz)'); ylabel('DFT Magnitude');
title('Discrete Fourier Transform');
subplot(3,1,3);
plot(F,magY); grid on; xlim([0 2000]);
xlabel('Frequency (Hz)'); ylabel('DFT Magnitude');
title('Discrete Fourier Transform');
for i=1:10
E(i)=abs(y(i).^2);
if i==1
disp(['The energy at fundamental frequency is ' num2str(E(i)) '.']);
else
disp(['The energy at 'num2str(i-1)' harmonic is 'num2str(E(i)) '.']);
end
end
TASK#2:
TASK#3: