Professional Documents
Culture Documents
Answer:
Q10.2:
Using MATLAB determine the lowest order of a digital IIR high-pass filter of all four types. The
specifications are as follows: sampling rate of 3,500 Hz, passband edge frequency of 1,050 Hz,
stopband edge frequency of 600 Hz, passband ripple of 1 dB, and a minimum stopband
attenuation of 50 dB. Comment on your results.
Answer:
The normalized passband edge angular frequency Wp is –
Q10.3:
Using MATLAB determine the lowest order of a digital IIR bandpass filter of all four types. The
specifications are as follows: sampling rate of 7 kHz, passband edge frequencies at 1.4 kHz and
2.1 kHz, stopband edge frequencies at 1.05 kHz and 2.45 kHz, passband ripple of 0.4 dB, and a
minimum stopband attenuation of 50 dB. Comment on your results.
Answer:
Q10.4:
Using MATLAB determine the lowest order of a digital IIR band-stop filter of all four types. The
specifications are as follows: sampling rate of 12 kHz, passband edge frequencies at 2.1 kHz and
4.5 kHz, stopband edge frequencies at 2.7 kHz and 3.9 kHz, passband ripple of 0.6 dB, and a
minimum stopband attenuation of 45 dB. Comment on your results.
Answer:
The normalized passband edge angular frequency Wp is –
Q10.5:
Design the Butterworth band-stop filter by running Program P10_1. Write down the exact expressionfor
the transfer function generated. What are the filter specifications? Does your design meet the
specifications? Using MATLAB, compute and plot the filter’s unwrapped phase response and the group
delay response.
Code: (a)
% Program P10_1
[num,den] = butter(N1,Wn1,'stop');
[g, w] = gain(num,den);
plot(w/pi,g);grid
Graph:
The filter specifications are: ωp.1 = 0.2
Code: (b)
% Program P10_5b
[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;
% axis([0 1 a b]);
GR = grpdelay(num,den,wg);
figure(2);
plot(wg/pi,GR);
grid;
%axis([0 1 a b]);
Graph:
Q10.6:
Modify Program P10_1 to design a Type 1 Chebyshev low-pass filter meeting the specifications
givenin Question Q10.1. Write down the exact expression for the transfer function generated.
Does your design meetthe specifications? Using MATLAB, compute and plot the filter’s
unwrapped phase response and the group delay response.
Code: (a)
% Program P10_1a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
[num,den] = cheby1(N,Rp,Wn);
[g, w] = gain(num,den);
figure(1);
plot(w/pi,g);grid;
Code: (b)
% Program P10_1b
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Design spec
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
[num,den] = cheby1(N,Rp,Wn);
[g, w] = gain(num,den);
figure(1);
plot(w/pi,g);grid;
figure(2);
w2 = 0:pi/511:pi;
Hz = freqz(num,den,w2);
Phase = unwrap(angle(Hz));
plot(w2/pi,Phase);grid;
figure(3);
GR = grpdelay(num,den,w2);
plot(w2/pi,GR);grid;
Graph:
Q10.7:
Modify Program P11_1 to design a Type 2 Chebyshev high-pass filter meeting the specifications
givenin Question Q11.2. Write down the exact expression for the transfer function generated.
Does your design meet the specifications? Using MATLAB, compute and plot the filter’s
unwrapped phase response and the group delay response.
Code: (a)
% Program P10_1a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
[num,den] = cheby2(N,Rs,Wn,'high');
[g, w] = gain(num,den);
figure(1);
% 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;
tmpX = ones(1,length(tmpY))*Ws;
tmpY = ones(1,length(w))*(-Rp);
tmpY = ones(1,length(w))*(-Rs);
plot(w/pi,g);grid;
Code: (b)
% Program P10_1b
% Design spec
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
[num,den] = cheby2(N,Rs,Wn,'high');
[g, w] = gain(num,den);
figure(1);
% 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;
tmpY = ones(1,length(w))*(-Rp);
tmpY = ones(1,length(w))*(-Rs);
plot(w/pi,g);grid;
hold off;
figure(2);
w2 = 0:pi/511:pi;
Hz = freqz(num,den,w2);
Phase = unwrap(angle(Hz));
plot(w2/pi,Phase);grid;
figure(3);
GR = grpdelay(num,den,w2);
plot(w2/pi,GR);grid;
Q10.8:
Modify Program P10_1 to design an elliptic bandpass filter meeting the specifications given in
QuestionQ10.2. Write down the exact expression for the transfer function generated. Does your
design meet the specifications? Using MATLAB, compute and plot the filter’s unwrapped phase
response and the group delayresponse.
Code: (a)
% Program P10_1a
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Design spec as given in Q7.3.
omega_p1 = 2*pi*Fp1/FT;
omega_p2 = 2*pi*Fp2/FT;
Wp = [Wp1 Wp2];
omega_s1 = 2*pi*Fs1/FT;
omega_s2 = 2*pi*Fs2/FT;
Ws = [Ws1 Ws2];
[num,den] = ellip(N,Rp,Rs,Wn);
[g, w] = gain(num,den);
% Plot the gain response
figure(1);
% 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;
tmpX = ones(1,length(tmpY))*Wp2;
tmpX = ones(1,length(tmpY))*Ws1;
tmpX = ones(1,length(tmpY))*Ws2;
tmpY = ones(1,length(w))*(-Rp);
tmpY = ones(1,length(w))*(-Rs);
plot(w/pi,g);grid;
18
Graph:
Code: (b)
% Program P10_5d
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
omega_p1 = 2*pi*Fp1/FT;
omega_p2 = 2*pi*Fp2/FT;
Wp = [Wp1 Wp2];
omega_s1 = 2*pi*Fs1/FT;
omega_s2 = 2*pi*Fs2/FT;
Ws = [Ws1 Ws2];
[num,den] = ellip(N,Rp,Rs,Wn);
[g, w] = gain(num,den);
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;
tmpX = ones(1,length(tmpY))*Wp2;
tmpX = ones(1,length(tmpY))*Ws1;
tmpX = ones(1,length(tmpY))*Ws2;
tmpY = ones(1,length(w))*(-Rp);
tmpY = ones(1,length(w))*(-Rs);
plot(w/pi,g);grid;
hold off;
figure(2);
w2 = 0:pi/511:pi;
Hz = freqz(num,den,w2);
Phase = unwrap(angle(Hz));
plot(w2/pi,Phase);grid;
figure(3);
GR = grpdelay(num,den,w2);
plot(w2/pi,GR);grid;
graph: