% short script to illustrate convolution as in windows. % written 11/7/02 - rms % Still needs work and annotation % Indexing also does not seem quite right figure N = 20; %length of window wc = .4*pi; % cutoff of LPF Nplot = 21; % Number of plot iterations plotinc = .01*pi; w = -pi: plotinc : pi; Nw = length(w); Hd = (abs(w) <= wc); subplot(4,1,1),plot(w/pi,Hd); axis([-1 1 0 1.25]); W = sincdt(w,N); subplot(4,1,2), plot(w/pi,W) axis([-1 1 -N/2 1.25*N]); % Precomputing output H = (1/(2*pi))*ifft(fft(W,Nw).*conj(fft(Hd,Nw)),Nw); H = real(H); % true within 1% almost all of the time H = rotateR(H,floor(Nw/2)); pause for l = 0:Nplot Nrot = mod(floor((Nw/2)+(l*(Nw/Nplot))),Nw); % N/2 term is to move lobe to side temp = RotateR(W,Nrot); prod = temp.*Hd; subplot(4,1,2),plot(w/pi,temp); axis([-1 1 -N/2 1.25*N]); subplot(4,1,3),plot(w/pi,prod); axis([-1 1 -N/2 1.25*N]); index = (1:Nw <= l*Nw/Nplot); subplot(4,1,4),plot(w/pi,H.*index); % subplot(4,1,4),plot(w(1:10*(l))/pi,H(1:10*(l)).*index(1:10*(l))); axis([-1 1 -N 3*N]) pause end