%% matlab code x1=sin(2*pi*1*[0:63]/16)'; x2=sin(2*pi*2*[0:63]/16)'; clf y=(x1+x2).*hamming(length(x1+x2)); plot([0:length(y)-1]*16/length(y),log10(abs(fft(y))),'.') hold y=[zeros(length(y)/2,1); y; zeros(length(y)/2,1)]; plot([0:length(y)-1]*16/length(y),log10(abs(fft(y))),'go') y=[zeros(length(y)/2,1); y; zeros(length(y)/2,1)]; plot([0:length(y)-1]*16/length(y),log10(abs(fft(y))),'rx') xlabel('Hz') grid ylabel ('log magnitude') legend({'no pad','zero padded*2','zero padded*4'}) title('1 Hz, 2 Hz components') print -djpeg99 -r300 1_2Hz.jpg x1=sin(2*pi*1.125*[0:63]/16)'; clf y=(x1+x2).*hamming(length(x1+x2)); plot([0:length(y)-1]*16/length(y),log10(abs(fft(y))),'.') hold y=[zeros(length(y)/2,1); y; zeros(length(y)/2,1)]; plot([0:length(y)-1]*16/length(y),log10(abs(fft(y))),'go') y=[zeros(length(y)/2,1); y; zeros(length(y)/2,1)]; plot([0:length(y)-1]*16/length(y),log10(abs(fft(y))),'rx') xlabel(Hz) xlabel('Hz') grid ylabel ('log magnitude') legend({'no pad','zero padded*2','zero padded*4'}) title('1.125 Hz, 2 Hz components') print -djpeg99 -r300 1125_2Hz.jpg