Review Section M9.3 FIR Filter Design by Frequency sampling (pp. 885-886). Then
ID: 2082628 • Letter: R
Question
Review Section M9.3 FIR Filter Design by Frequency sampling (pp. 885-886). Then design a low pass filter with a cut-off frequency T/4. Generate the plots for the filter coefficients for filter lengths N 21 and N 41 using the code given for MS9P2. You will also need the MS5P1 function from p. 573. Then generate a low pass filter with a cut-off frequenc s2c 3T/8. Again, generate the plots for filter lengths N-21 and 41. Turn in the following 1. Plots for all the cases above. 2. The code for the last part with 2 3 /8 3. A brief explanation on (a) how the cut-off frequency nerelates to the specifications for a physically implemented filter, (b) what is the "poor behavior" of the filter and how its performance can be improved.Explanation / Answer
Copy the following code to a new function file in MATLAB. Name the file MS9P2.m
function [h] = MS9P2(N,H_d)
Omega = linspace(0,2*pi*(1-1/N),N)';
H = 1.0*H_d(Omega);
h = real(ifft(H));
end
Copy the following code to a new function file in MATLAB. Name the function MS5P1.m
function [H] = MS5P1(B,A,Omega)
N_1 = length(B)-1; N_2 = length(A)-1;
H = polyval(B,exp(j*Omega))./polyval(A,exp(j*Omega)).*exp(j*Omega*(N_2-N_1));
end
Copy the following code to a new script file in MATLAB.
close all; clear all; clc;
% ideal frequency response with cutoff frequency pi/4
H_d = inline('(mod (Omega, 2*pi)<pi/4) + (mod (Omega, 2*pi) > 2*pi-pi/4)');
%%%%%%% N = 21 %%%%%%%%
N = 21; h=MS9P2(N, H_d);
Omega = linspace(0,2*pi,1000); samples = linspace(0,2*pi*(1-1/N),N);
H = MS5P1(h,1,Omega);
figure; subplot(2,1,1); stem([0:N-1],h,'k'); xlabel('n'); ylabel('h[n]');
title('Lowpass Filter Omega_{c} = pi/4 (N=21)');
subplot(2,1,2);
plot(samples, H_d(samples),'ko',Omega, H_d(Omega), 'k:',Omega,abs(H),'k');
axis([0 2*pi -0.1 1.6]); xlabel('Omega'); ylabel('|H(Omega)|');
legend('Samples','Desired','Actual',0);
%%%%%%% N=41 %%%%%%%%%
N = 41; h=MS9P2(N, H_d);
Omega = linspace(0,2*pi,1000); samples = linspace(0,2*pi*(1-1/N),N)';
H = MS5P1(h,1,Omega);
figure; subplot(2,1,1); stem([0:N-1],h,'k'); xlabel('n'); ylabel('h[n]');
title('Lowpass Filter Omega_{c} = pi/4 (N=41)');
subplot(2,1,2);
plot(samples, H_d(samples),'ko',Omega, H_d(Omega), 'k:',Omega,abs(H),'k');
axis([0 2*pi -0.1 1.6]); xlabel('Omega'); ylabel('|H(Omega)|');
legend('Samples','Desired','Actual',0);
% ideal frequency response with cutoff frequency 3*pi/8
H_d = inline('(mod (Omega, 2*pi)<3*pi/8) + (mod (Omega, 2*pi) > 2*pi-3*pi/8)');
%%%%%%% N = 21 %%%%%%%%
N = 21; h=MS9P2(N, H_d);
Omega = linspace(0,2*pi,1000); samples = linspace(0,2*pi*(1-1/N),N);
H = MS5P1(h,1,Omega);
figure; subplot(2,1,1); stem([0:N-1],h,'k'); xlabel('n'); ylabel('h[n]');
title('Lowpass Filter Omega_{c} = 3pi/8 (N=21)');
subplot(2,1,2);
plot(samples, H_d(samples),'ko',Omega, H_d(Omega), 'k:',Omega,abs(H),'k');
axis([0 2*pi -0.1 1.6]); xlabel('Omega'); ylabel('|H(Omega)|');
legend('Samples','Desired','Actual',0);
%%%%%%% N=41 %%%%%%%%%
N = 41; h=MS9P2(N, H_d);
Omega = linspace(0,2*pi,1000); samples = linspace(0,2*pi*(1-1/N),N)';
H = MS5P1(h,1,Omega);
figure; subplot(2,1,1); stem([0:N-1],h,'k'); xlabel('n'); ylabel('h[n]');
title('Lowpass Filter Omega_{c} = 3pi/8 (N=41)');
subplot(2,1,2);
plot(samples, H_d(samples),'ko',Omega, H_d(Omega), 'k:',Omega,abs(H),'k');
axis([0 2*pi -0.1 1.6]); xlabel('Omega'); ylabel('|H(Omega)|');
legend('Samples','Desired','Actual',0);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.