clear all close all clc % Experiment 2..... Aliasing Effect f1=10;w1=2*pi*f1; f2=20;w2=2*pi*f2; f3=30;w3=2*pi*f3; L=100; % Length of signal fs=40; % Sampling freq Ts=1/fs; t=(0:(L-1))*Ts; x1=sin(w1*t); x2=sin(w2*t); x3=sin(w3*t); x=x1+x2+x3; subplot(2,1,1) plot(t,x) xlabel("time t") ylabel("x(t)") title("continuous signal x(t)") subplot(2,1,2) stem(t,x) xlabel("time nTs") ylabel("x(nTs)") title("sampled signaL x(nTs)") Y=fft(x); subplot(3,1,1) freq1=(0:L-1)*fs/L; plot(freq1, abs(Y)); xlabel("frequency") ylabel("magnitude") title("fft spectrum of x(t)") subplot(3,1,2) freq2=(-L/2:L/2-1)*fs/L; plot(freq2, abs(fftshift(Y))); xlabel("freq") ylabel("mag") title("fft spectrum in +ve and -ve frequencies") subplot(3,1,3) freq2=(-L/2:L/2-1)*fs/L; plot(freq2, abs(fftshift(Y))); xlabel("freq") ylabel("mag") title("fft spectrum in +ve frequencies") axis([0 fs/2 0 max(abs(Y))])