%Demo done during Session 22 to illustrate %the effects of truncating a sum of %two sinewaves -- we analyze the effects %as a function of the separation in %frequency and the differential in %amplitude amongst the two sinewaves % clf set(0,'defaultaxesfontsize',22); x=cos(2*pi*6.5*(0:31)/32)+cos(2*pi*6*(0:31)/32); freqomega=linspace(-pi,pi,1024); z=abs(fftshift(fft(x,1024))); fmag=20*log10(abs(z)); fmag=fmag-max(fmag); clg plot(freqomega,fmag,'LineWidth',4); axis([-pi pi -30 0]); title('DTFT of Two Closely-Spaced Sinusoids'),... xlabel('Omega'), ylabel('Magnitude (dB)'), grid hold on Ws1=2*pi*(6/32); Ws2=2*pi*(6.5/32); plot([Ws1 Ws1],[-30 0],'m--','LineWidth',4) plot([Ws2 Ws2],[-30 0],'m--','LineWidth',4) hold off pause x=20*cos(2*pi*5*(0:31)/32)+cos(2*pi*12*(0:31)/32); z=abs(fftshift(fft(x,1024))); fmag=20*log10(abs(z)); fmag=fmag-max(fmag); clg plot(freqomega,fmag,'LineWidth',3); axis([-pi pi -30 0]); title('DTFT of Two Sinusoids with Diverse Amplitudes'),... xlabel('Omega'), ylabel('Magnitude (dB)'), grid hold on Ws1=2*pi*(5/32); Ws2=2*pi*(12/32); plot([Ws1 Ws1],[-30 0],'m--','LineWidth',4) plot([Ws2 Ws2],[-30 0],'m--','LineWidth',4) hold off