Hints for plotting windows:
Remember you need to plot the envelope of the window so you want the
computational resolution to be very fine. Also, for some windows you will get
zeros in the spectrum which causes difficulties with the log10 function.
n1=0:1:15;
w1=hamming(length(n1));
w2=boxcar(length(n1));
%find DFT, zero pad to length 512 to get the envelope
W1=fft(w1,512);W2=fft(w2,512);
% Normalize to one
W1=W1/max(abs(W1));W2=W2/max(abs(W2));
%calculate result in db, note that the maximum value removes the zeros in the
spectrum
W1=20*log10(abs(W1));W2=20*log10(max(abs(W2),1e-10));
len=length(W1)/2;
halfn=0:1:len-1;
plot(halfn*pi/len,W1(1:len),'g-',halfn*pi/len,W2(1:len),'b-.');
axis([0 pi -80 0]);
title('sidelobe height comparison, L=16');
xlabel('radians');ylabel('Magnitude (dB)');
Page last updated 09/17/00