In: Electrical Engineering
Q7.1 The normalized passband edge angular frequency
Wp is - 0.2
The normalized stopband edge angular frequency Ws is -
0.4
The desired passband ripple Rp is - 0.5 dB
The desired stopband ripple Rs is - 40 dB
In Matlab:
Q7.X1 Design a Butterworth lowpass filter satisfying the specifications in Q7.1. Plot the magnitude and phase responses. Also include magnified plots of passband and stopband showing how well the filter satisfies the design specifications.
Script:
clc;close all;clear all;
Wp =0.2
Ws =0.4
Rp=0.5;Rs=40;
%Butterworth filter
[N,wc]=buttord(Wp,Ws,Rp,Rs)
[b,a]=butter(N,wc)
%Frequency response
w=0:pi/1000:pi
H=freqz(b,a,w)
figure;
subplot(221)
plot(w/pi,20*log10(abs(H)),'LineWidth',3,'m')
xlabel('w X pi');grid;
ylabel('|H(exp(jw)|')
title('Magnitude response')
subplot(222)
plot(w/pi,angle(H),'LineWidth',3,'r')
xlabel('w X pi');grid;
ylabel('<H(exp(jw)>')
title('Phase response')
subplot(223)
plot(w/pi,20*log10(abs(H)),'LineWidth',3,'r')
xlabel('w X pi');grid;
ylabel('|H(exp(jw)|')
title('Magnified pass band')
xlim([0 0.2])
ylim([-20 2])
subplot(224)
plot(w/pi,20*log10(abs(H)),'LineWidth',3,'b')
xlabel('w X pi');grid;
ylabel('|H(exp(jw)|')
title('Magnified stop band')
xlim([0.4 1])
ylim([-500 0])
%stop band attenuation achieved from the design
Hdb=20*log10(abs(H))
Sdb=Hdb(find(w==0.4*pi))
Pdb=Hdb(find(w==0.2*pi))
Command window:
Sdb = -46.782
Pdb = -0.50000