clear all; close all; warning('off','MATLAB:dispatcher:InexactMatch') % 2nd Homework 'Make some of IIR filter' % #1 % (a)For Ex 6-1, draw |H(§Ù)| and |H(§Ù)| [dB] w= 0:0.001:pi; z= exp(j*w); N= 0:23; % (b) For input x[n]= cos(pi*n/6) + cos(pi*n/2) , n=0,1,2,¡¦..23 % Draw |X(§Ù)|, |Y(§Ù)| where Y(§Ù)= X(§Ù)*H(§Ù) [A_Y, A_in_H, DB, A_H] = hw2(2, z, cos((pi/6)*N)+cos((pi/2)*N), 3142); figure('name', '#1', 'Position', [100, 150, 800, 600], 'MenuBar', 'none') subplot(2,2,1); plot(A_H); title('Response H(§Ù)'); hold on; subplot(2,2,2); plot(DB); title('Response in dB'); grid; ylabel('Decibels'); subplot(2,2,3); plot(A_in_H); title('Response X(§Ù)'); subplot(2,2,4); plot(A_Y); title('Response Y(§Ù)'); % #2 % (a)Passband centered at §Ù=pi/4 with a BW of pi/40 between -3dB points % Peak gain is unity % Perfect rejection at §Ù=0 and §Ù= pi/2 % (b) For input x[n]= cos(pi*n/6) + cos(pi*n/2) , n=0,1,2,¡¦..23 % Draw |X(§Ù)|, |Y(§Ù)| where Y(§Ù)= X(§Ù)*H(§Ù) [A_Y, A_in_H, DB, A_H] = hw2(4, z, cos((pi/6)*N)+cos((pi/2)*N), 3142); figure('name', '#2', 'Position', [150, 100, 800, 600], 'MenuBar', 'none') subplot(2,2,1); plot(A_H); title('Response H(§Ù)'); hold on; subplot(2,2,2); plot(DB); title('Response in dB'); grid; ylabel('Decibels'); subplot(2,2,3); plot(A_in_H); title('Response X(§Ù)'); subplot(2,2,4); plot(A_Y); title('Response Y(§Ù)'); % % #3 % % Ex 6-2 draw |H1(§Ù)|, |H2(§Ù)|, |H(§Ù)| H1= 1./(z.^2-1.9476.*z*cos(pi/10)+0.9483); H2= z.^2-2.*z*cos(pi/10)+1; H3= H1.*H2; figure('name', '#3 |H1(§Ù)|, |H2(§Ù)|, |H(§Ù)|', 'Position', [200, 50, 800, 600], 'MenuBar', 'none') subplot(2,2,1); plot(abs(H1)); title('Response H1(§Ù)'); hold on; subplot(2,2,2); plot(abs(H2)); title('Response H2(§Ù)'); subplot(2,1,2); plot(abs(H3)); title('Response H(§Ù)');