set(0,'defaultaxesfontsize',22); clear all clf a=0.8; N=51; off=(N-1)/2; Nfft=1024; Xa=zeros(1,Nfft); wd=linspace(0,2*pi-2*pi/Nfft,Nfft); wda=linspace(0,2*pi-2*pi/N,N); Xw=((1-a^2)./((1-2*a*cos(wda)+a^2))).*exp(-j*wda*off); Xorig=((1-a^2)./((1-2*a*cos(wd)+a^2))); Xoriga=((1-a^2)./((1-2*a*cos(wda)+a^2))); xa=real(fftshift(ifft(Xoriga,N))); Xrec=abs(fft(xa,Nfft)); for k=0:N-1; wk=2*pi*k/N; Xk=(1-a^2)./((1-2*a*cos(wk)+a^2)); %Xa=Xa+Xk*(sin((wd-wk)*N/2).*exp(-j*(wd-wk)*(N-1)/2))./(N*sin((wd-wk)/2)); Xa=Xa+Xk*(sin((wd-wk)*N/2)./(N*sin((wd-wk)/2))); end plot(wd,Xa,'b','Linewidth',3) hold on plot(wd,Xorig,'r','Linewidth',3) plot(wd,Xrec,'k','Linewidth',3) legend('Reconstructed Spectrum from N samples','True Spectrum','Zero-Padded FFT of IFFT of N samples') hold off pause n=-off:off; plot(n,xa,'b','Linewidth',3); xalias=a.^abs(n)+a.^abs(n-N)+ a.^abs(n+N); hold on plot(n,xalias,'k','Linewidth',3) plot(n,a.^abs(n),'r','Linewidth',3) legend('N-pt IFFT of sampled X(w)','Time-Domain Aliasing Formula','True x[n]') hold off