%simulation of performance of IIR digital filter %Fc = 3.5Khz Fs = 10Khz N = 3 %Transformation method: Bilinear Transform using pole-zero method. clear NUM_OF_POINTS = 512; %Number of frequency points for the filter B = [1 3 3 1]; %zeros of the filter A = [1 1.163 .697 .138]; %poles of the filter K = .375; %filter gain F = 3.5e3; %desired cutoff frequency Fs = 10e3; %sampling frequency B = B*K; %add scaling. [H,W]=freqz(B,A,NUM_OF_POINTS); %Obtain the frequency responce of the filter %figure,plot(F,abs(H)),grid,title('Magnitude Response |H(z)|'),xlabel('Frequency'),ylabel('Magnitude'); subplot(2,2,1),plot(W/pi,20*log10(abs(H)/1)),grid,title('Magnitude Response |H(z)| in dB'),xlabel('Normalized Frequency 0 < Fn < 1'),ylabel('Magnitude (dB)'),axis([0 1 -10 0]); subplot(2,2,2),plot(W/pi,angle(H)),grid,title('Phase Response'),xlabel('Normalized Frequency 0 < Fn < 1'),ylabel('Phase in Radians'); [Z,P,K]=tf2zp(B,A); %Get zeros and poles of transfer function. subplot(2,2,3),zplane(Z,P),title('Z-plane plot'),legend('Zeros','Poles'); %plot Z-Plane of IIR filter subplot(2,2,4),grpdelay(B,A),title('Group Delay'); %Plot group delay Fn = F/(Fs/2) disp 'Filter Coefficients. B = Numerator Coefficients A = Denominator Coefficients'; disp 'Poles = P Zeros = Z Gain = K'; disp '----------------------------------------'; B A P Z K