7. Optimal Lowpass Filter. Use the MATLAB command h = firpm(28, [0 0.30 0.36 1], [1 1 0 0]) to design an optimal lowpass filter with length 29, passband from 0 to wp = 0.30pi and a stopband from ws = 0.36pi to pi with a desired response of 1 in the passband and zero in the stopband. (Assume equal error weighting in both the passband and stopband for the optimal filter in all exercises except Exercise 11.) Plot the impulse response and the magnitude frequency response of the filter. By hand, circle the alternation points.
MATLAB code for impulse response and magnitude response is shown below:
h = firpm(28, [0 0.30 0.36 1], [1 1 0 0]);
w = (-pi:pi/100:pi);
z = exp(-j*w);
for i = 1:length(h)
h1(i,1:length(z)) = z.^(i-1);
end
semilogx(w/pi,20*log10(abs(htf)))
plot(w/pi,20*log10(abs(htf)))
grid on
hold all
xlabel('\omega/\pi')
ylabel('magnitude(dB)')
figure
stem((0:1:length(h)-1),h);
Impulse response is shown below:
Magnitude response is shown below:
Get Answers For Free
Most questions answered within 1 hours.