global_decl; plat = platform('octave'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% w0=0; A0=1; % Response at dc w1=pi/3; A1=0.1^(1/5); % Response at Fs/6 (1/5 of 20 dB) %% coefficients of the length-3 FIR filter A = [1 2*cos(w0); 1 2*cos(w1)]; b = [A0; A1]; a = A\b; a1 = a(1) a0 = a(2) w = [0:0.01:pi]; %% frequency response of the length-3 FIR filter H = a0 + a1*exp(-i*w) + a0*exp(-i*2*w); %% frequency response of the length-11 FIR filter %% (cascade of 5 length-3 filters) H11 = H.^5; subplot(2,2,1); plot(w, 20*log10(abs(H11))); xlabel('frequency [rad/sample]'); ylabel('magnitude [dB]'); axis([0,pi,-90,0]); grid; eval(myreplot); %print -deps2 'ampfir3.eps' pause; %% pole-zero plot %% In Matlab, it can be done with %% the single line: %% zplane(roots([a0,a1,a0]),0); w_all = [0:0.05:2*pi]; subplot(2,2,2); plot(exp(i*w_all), '.'); hold on; zeri = roots([a0, a1, a0]); plot(real(zeri),imag(zeri), 'o'); plot(0,0, 'x'); hold off; xlabel('Re'); ylabel('Im'); axis ([-1.2, 1.2, -1.2, 1.2]); if (plat=='matlab') axis ('square'); end; eval(myreplot); %print -deps2 'zerifir3.eps' pause; % kernelw=ones(size(w)); % for k=1:10 kernelw=[kernelw; exp(-i*k*w)]; end; k = [0:10]'; kernelw = exp(-i*k*w); aa = H11 / kernelw subplot(2,2,3); plot([0:10],real(aa),'+'); xlabel('samples'); ylabel('h'); grid; axis; eval(myreplot); %print -deps2 'fir11.eps' aa2 = conv([a0 a1 a0],[a0 a1 a0]); aa3 = conv(aa2,[a0 a1 a0]); aa4 = conv(aa3,[a0 a1 a0]); aa5 = conv(aa4,[a0 a1 a0]) %% verify that aa5 = aa: by composition of convolutions we get %% the same length-11 filter