Académique Documents
Professionnel Documents
Culture Documents
N= 8 Wn = 0.2469
0
Magnitude (dB)
0.1
0.2
0.9
Phase (degrees)
0.1
0.2
0.9
(2) Using these values and cheb1ord we get the lowest order for a Type 1 Chebyshev lowpass filter to be - the correct call is
200
Magnitude (dB)
-200
-400
0.1
0.2
0.9
Phase (degrees)
-200
-400
-600
0.1
0.2
0.9
(3) Using these values and cheb2ord we get the lowest order for a Type 2 Chebyshev lowpass filter to be - the correct call is
Magnitude (dB)
-100
-200
-300
0.1
0.2
0.9
Phase (degrees)
-200
-400
-600
0.1
0.2
0.9
(4) Using these values and ellipord we get the lowest order for an elliptic lowpass filter to be - the correct call is [N, Wn] = ellipord(0.2,0.4,0.5,40). This gives :
N=4 Wn = 0.2000
100
Magnitude (dB)
0.1
0.2
0.9
Phase (degrees)
0.1
0.2
0.9
From the above results we observe that the Elliptic filter has the lowest order meeting the specifications.
Q7.2:
FT= 3500Hz; Fp=1 ,05Hz; Fs=600Hz; Rp=1dB; Rs=5OdB
The normalized passband edge angular frequency Wp is: Wp=(2**Fp)/(FT*)= 0.6 The normalized stopband edge angular frequency Ws is: Ws=(2**Fs)/(FT*)= 0.3428 (1) Using these values and buttord we get the lowest order for a Butterworth highpass filter to be the correct call is [N, Wn] = buttord(Wp,Ws,Rp,Rs). This gives :
N=8 Wn = 0.5646
Magnitude (dB)
0.1
0.2
0.9
Phase (degrees)
0.1
0.2
0.9
(2) Using these values and cheb1ord we get the lowest order for a Type 1 Chebyshev highpass filter to be the correct call is [N,Wn] = cheb1ord(Wp,Ws,Rp,Rs).
Magnitude (dB)
-100
-200
-300
0.1
0.2
0.9
Phase (degrees)
-200
-400
-600
0.1
0.2
0.9
(3) Using these values and cheb2ord we get the lowest order for a Type 2 Chebyshev highpass filter to be the correct call is [N,Wn] = cheb2ord(Wp,Ws,Rp,Rs).
N=4. Wn = 0.6000
From the above results we observe that the Elliptic filter has the lowest order meeting the Specifications
Q7.3:
FT= 7KHz; Fp,1= 1.4kHz; Fp,2= 2.1kHz Fs,1=1.05KHz; Fs,2=2.1KHz Rp=0.4dB; Rs=4OdB
The normalized passband edge angular frequency Wp is:
200
Magnitude (dB)
0.1
0.2
0.9
1000
Phase (degrees)
-1000
-2000
0.1
0.2
0.9
(2) Using these values and cheb1ord we get the lowest order for a Type 1 Chebyshev bandpass filter to be the correct call is [N,Wn] = cheb1ord(Wp,Ws,Rp,Rs)
200
Magnitude (dB)
-200
-400
0.1
0.2
0.9
500
Phase (degrees)
-500
-1000
0.1
0.2
0.9
(3) Using these values and cheb2ord we get the lowest order for a Type 2 Chebyshev bandpass filter to be the correct call is [N,Wn] = cheb2ord(Wp,Ws,Rp,Rs)
Magnitude (dB)
-100
-200
-300
0.1
0.2
0.9
500
Phase (degrees)
-500
-1000
0.1
0.2
0.9
(4) Using these values and ellipord we get the lowest order for an elliptic bandpass filter to be the correct call is [N,Wn] = ellipord(Wp,Ws,Rp,Rs) =
Magnitude (dB)
-100
-200
-300
0.1
0.2
0.9
Phase (degrees)
0.1
0.2
0.9
From the above results we observe that the Elliptic filter has the lowest order meeting the Specifications
Q7.4:
The normalized passband edge angular frequency Wp is:
Magnitude (dB)
0.1
0.2
0.9
1000
Phase (degrees)
-1000
-2000
0.1
0.2
0.9
(2) Using these values and cheb1ord we get the lowest order for a Type 1 Chebyshev bandstop filter to be the correct call is [N,Wn] = cheb1ord(Wp,Ws,Rp,Rs)
Magnitude (dB)
-100
-200
-300
0.1
0.2
0.9
500
Phase (degrees)
-500
-1000
0.1
0.2
0.9
(3) Using these values and cheb2ord we get the lowest order for a Type 2 Chebyshev bandstop filter to be the correct call is [N,Wn] = cheb2ord(Wp,Ws,Rp,Rs)
Magnitude (dB)
-100
-200
-300
0.1
0.2
0.9
500
Phase (degrees)
-500
-1000
0.1
0.2
0.9
(4) Using these values and ellipord we get the lowest order for an elliptic bandstop filter to be the correct call is [N,Wn] = ellipord(Wp,Ws,Rp,Rs) =
Magnitude (dB)
0.1
0.2
0.9
Phase (degrees)
0.1
0.2
0.9
A copy of Program P7_1 is given below: % Program P7_1 % Design of a Butterworth Bandstop Digital Filter Ws = [0.4 0.6]; Wp = [0.3 0.7]; Rp = 0.4; Rs = 50; % Estimate the Filter Order [N1, Wn1] = buttord(Wp, Ws, Rp, Rs); % Design the Filter [num,den] = butter(N1,Wn1,'stop'); % Display the transfer function disp('Numerator Coefficients are ');disp(num); disp('Denominator Coefficients are ');disp(den); % Compute the gain response [g, w] = gain(num,den); % Plot the gain response plot(w/pi,g);grid axis([0 1 -60 5]); xlabel('\omega /\pi'); ylabel('Gain in dB'); title('Gain Response of a Butterworth Bandstop Filter');
Q7.5
The coefficients of the Butterworth bandstop transfer function generated by running Program P7_1 are as follows:
Numerator Coefficients are 0.0330 0.0000 1.1889 0.0000 4.1611 0.0000 0.2972 0.0001 0.2972 0.0000 4.1611 0.0000 1.1889 0.0000 0.0330 0.0000 2.7741 2.7741 0.0000
1.0000
0.0000
2.6621
0.0000
4.1451
0.0001
4.1273
0.0001 0.1178
2.8977 0.0000
0.0000 0.0167
1.4381 0.0000
0.0000
0.5027
0.0000
0.0011 The exact expression for the transfer function is H(z)= (0.033 + 0.2972*z-2 + 1.1889*z-4 + 2.7741*z-6 + 4.1611*z-8 + 0.0001*z-9 + 4.1611*z-10 +2.7741*z-12 + 1.1889*z-14 +4.1611*z-16 +0.033*z-18) / (1 + 2.6621*z-2 + 4.1451*z-4 + 0.0001*z-5 + 4.1273*z-6 + 0.0001*z-7+ 2.8977*z-8 + 1.4381*z-10 +0.5027*z-12 + 0.1178*z-14 +0.0167*z-16 +0.011*z-18)
The filter specifications are: wp1= 0.3*pi , ws1 0.4 ws2 0.6*pi The gain response of the filter as designed is given below:
wp2= 0.7
-10
-20
Gain in dB
-30
-40
-50
-60
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
From the plot we conclude that the design MEETS the specifications. The plot of the unwrapped phase response and the group delay response of this filter is given Below
Here is the program to find and plot the unwrapped phase response and group delay:
Ws = [0.4 0.6]; Wp = [0.3 0.7]; Rp = 0.4; Rs = 50; [N1, Wn1] = buttord(Wp, Ws, Rp, Rs); [num,den] = butter(N1,Wn1,'stop'); wp = 0:pi/1023:pi; wg = 0:pi/511:pi; Hz = freqz(num,den,wp); Phase = unwrap(angle(Hz)); figure(1); plot(wp/pi,Phase); grid; xlabel('\omega /\pi'); ylabel('Unwrapped Phase (rad)'); title('Unwrapped Phase Response of a Butterworth Bandstop Filter'); GR = grpdelay(num,den,wg); figure(2); plot(wg/pi,GR); grid; xlabel('\omega /\pi'); ylabel('Group Delay (sec)'); title('Group Delay of a Butterworth Bandstop Filter');
1 0 -1 -2 -3 -4
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
3 0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Hz = freqz(num,den,w2); Phase = unwrap(angle(Hz)); plot(w2/pi,Phase);grid; xlabel('\omega /\pi'); ylabel('Unwrapped Phase (rad)'); title('Unwrapped Phase Response of a Type 1 Chebyshev Lowpass Filter'); % Find and plot the group delay figure(3); GR = grpdelay(num,den,w2); plot(w2/pi,GR);grid; xlabel('\omega /\pi'); ylabel('Group Delay (sec)'); title('Group Delay of a Type 1 Chebyshev Lowpass Filter');
Q7.6
The coefficients of the Type 1 Chebyshev lowpass transfer function for the parameters given in Question 7.1 and generated by running modified Program P7_1 are as follows :
Numerator Coefficients are 0.0004 0.0020 0.0040 0.0040 0.0020 0.0004 Denominator Coefficients are 1.0000 -3.8269 6.2742 -5.4464 2.4915 -0.4797 The exact expression for the transfer function is
-10
-20
Gain in dB
-30
-40
-50
-60
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
-3 -4 -5 -6 -7 -8
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
12 10 8 6 4 2 0
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
Q7.7:
% Program Q7_7 FT = 3.50*10^3; % sampling freq Fp = 1.05*10^3; % analog passband edge freq Fs = 0.60*10^3; % analog stopband edge freq Rp = 1.0; % max passband ripple, dB Rs = 50; % min stopband attenuation, dB % Convert spec to normalized digital frequencies omega_p = 2*pi*Fp/FT; Wp = 2*Fp/FT; % omega_p/pi omega_s = 2*pi*Fs/FT; Ws = 2*Fs/FT; % omega_s/pi % Estimate the Filter Order [N, Wn] = cheb2ord(Wp, Ws, Rp, Rs); % Design the Filter [num,den] = cheby2(N,Rs,Wn,'high'); % Display the transfer function disp('Numerator Coefficients are ');disp(num); disp('Denominator Coefficients are ');disp(den); % Compute the gain response [g, w] = gain(num,den); % Plot the gain response figure(1); axis([0 1 -60 5]); % Add lines to the plot to help determine if the spec was met. hold on; tmpY = -60:65/511:5; tmpX = ones(1,length(tmpY))*Wp; plot(tmpX,tmpY,'r-'); % vertical line at passband edge freq tmpX = ones(1,length(tmpY))*Ws; plot(tmpX,tmpY,'g-'); % vertical line at stopband edge freq tmpY = ones(1,length(w))*(-Rp); plot(w/pi,tmpY,'r-'); % horizontal line at Rp tmpY = ones(1,length(w))*(-Rs); plot(w/pi,tmpY,'g-'); % horizontal line at Rs % now plot the gain plot(w/pi,g);grid; xlabel('\omega /\pi'); ylabel('Gain in dB'); title('Gain Response of a Type 2 Chebyshev Highpass Filter'); hold off; % Find and plot the phase figure(2); w2 = 0:pi/511:pi; Hz = freqz(num,den,w2); Phase = unwrap(angle(Hz)); plot(w2/pi,Phase);grid; xlabel('\omega /\pi'); ylabel('Unwrapped Phase (rad)'); title('Unwrapped Phase Response of a Type 2 Chebyshev Highpass Filter'); % Find and plot the group delay figure(3); GR = grpdelay(num,den,w2); plot(w2/pi,GR);grid; xlabel('\omega /\pi'); ylabel('Group Delay (sec)'); title('Group Delay of a Type 2 Chebyshev Highpass Filter); The coefficients of the Type 1 Chebyshev highpass transfer function for the parameters given in Question 7.2 and generated by running modified Program P7_1 are as follows : Numerator Coefficients are 0.0671 -0.2404 0.4146 -0.4146 0.2404 -0.0671
Denominator Coefficients are 1.0000 0.2933 0.7303 0.0711 0.0783 0.0001 The exact expression for the transfer function is :
-10
-20
Gain in dB
-30
-40
-50
-60
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
0 0
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
Q7.8:
% Program Q7_8 FT = 7.00*10^3; % sampling freq Fp1 = 1.4*10^3; % analog lower passband edge freq Fp2 = 2.1*10^3; % analog upper passband edge freq Fs1 = 1.05*10^3; % analog lower stopband edge freq Fs2 = 2.45*10^3; % analog upper stopband edge freq Rp = 0.4; % max passband ripple, dB Rs = 50; % min stopband attenuation, dB % Convert spec to normalized digital frequencies omega_p1 = 2*pi*Fp1/FT; Wp1 = 2*Fp1/FT; % omega_p1/pi omega_p2 = 2*pi*Fp2/FT; Wp2 = 2*Fp2/FT; % omega_p2/pi Wp = [Wp1 Wp2]; omega_s1 = 2*pi*Fs1/FT; Ws1 = 2*Fs1/FT; % omega_s1/pi omega_s2 = 2*pi*Fs2/FT; Ws2 = 2*Fs2/FT; % omega_s2/pi Ws = [Ws1 Ws2]; % Estimate the Filter Order [N, Wn] = ellipord(Wp, Ws, Rp, Rs); % Design the Filter [num,den] = ellip(N,Rp,Rs,Wn); % Display the transfer function disp('Numerator Coefficients are ');disp(num); disp('Denominator Coefficients are ');disp(den); % Compute the gain response [g, w] = gain(num,den); % Plot the gain response figure(1); axis([0 1 -60 5]); % Add lines to the plot to help determine if the spec was met. hold on; tmpY = -60:65/511:5; tmpX = ones(1,length(tmpY))*Wp1; plot(tmpX,tmpY,'r-'); % vertical line at passband edge freq tmpX = ones(1,length(tmpY))*Wp2; plot(tmpX,tmpY,'r-'); % vertical line at passband edge freq tmpX = ones(1,length(tmpY))*Ws1; plot(tmpX,tmpY,'g-'); % vertical line at stopband edge freq tmpX = ones(1,length(tmpY))*Ws2; plot(tmpX,tmpY,'g-'); % vertical line at stopband edge freq tmpY = ones(1,length(w))*(-Rp); plot(w/pi,tmpY,'r-'); % horizontal line at Rp tmpY = ones(1,length(w))*(-Rs); plot(w/pi,tmpY,'g-'); % horizontal line at Rs % now plot the gain plot(w/pi,g);grid; xlabel('\omega /\pi'); ylabel('Gain in dB'); title('Gain Response of an Elliptic Bandpass Filter'); hold off; % Find and plot the phase figure(2); w2 = 0:pi/511:pi; Hz = freqz(num,den,w2); Phase = unwrap(angle(Hz)); plot(w2/pi,Phase);grid;
xlabel('\omega /\pi'); ylabel('Unwrapped Phase (rad)'); title('Unwrapped Phase Response of an Elliptic Bandpass Filter'); % Find and plot the group delay figure(3); GR = grpdelay(num,den,w2); plot(w2/pi,GR);grid; xlabel('\omega /\pi'); ylabel('Group Delay (sec)'); title('Group Delay of an Elliptic Bandpass Filter');
The coefficients of the elliptic bandpass transfer function for the parameters given in Question 7.3 and generated by running modified Program P7_1 are as follows : Numerator Coefficients are 0.0116 -0.0000 -0.0046 -0.0000 0.0166 -0.0000 -0.0046 -0.0000 0.0116 Denominator Coefficients are 1.0000 -0.0000 2.8611 -0.0000 3.4205 -0.0000 1.9609 -0.0000 0.4529 The exact expression for the transfer function is:
-10
-20
Gain in dB
-30
-40
-50
-60
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
-2
-4
-6
0.1
0.2
0.3
0.4
0.5 /
0.6
0.7
0.8
0.9
20
15
10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9