Lab No. 7
Lab No. 7
ATTOCK CAMPUS
LAB REPORT
Abdul Wahab
Group Members FA21-BEE-004
Task No.1:
Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two
components as f1 = 3kHz and f2 = 5kHz and then sample it with fs = 12kHz.
Calculate its fft with zero frequency component in the middle. Plot it on a properly
scaled w-axis. Specify if there is aliasing or not? If there is aliasing specify which
component is casing the aliasing.
S O U R C E C O D E
n = -50:50;
f1 = 3000; f2=5000;
fs = 12000;
x = sin(2*pi*(f1/fs)*n)+sin(2*pi*(f2/fs)*n) ;
subplot(2,1,1);
stem(n,x);
L = length(x);
NFFT = 2^nextpow2(L);
y = fft(x,NFFT);
f_ax1 = fs/2*linspace(0,1,NFFT/2+1);
f_ax2 = fs/2*linspace(-1,0,NFFT/2-1);
f_ax = [f_ax1 f_ax2];
stem(f_ax,2*abs(y));
O U T P U T:
120
100
80
60
40
20
0
-6000 -4000 -2000 0 2000 4000 6000
Figure 1