Question

2. Design a digital lowpass filter to meet the following specifications: passband edge = 0.45π stopband...

2. Design a digital lowpass filter to meet the following specifications: passband edge = 0.45π stopband edge = 0.5π Rp = 0.5 dB, As = 60 dB a. Design a Buttterworth filter, you may use the butterord and butter commands to implement. b. Design Chebyshev Type 1 filter ( use the equivalent commands to above ) c. Design an Elliptic fitler ( use the equivalent commands to part a ). d. List the order of each filter and find the actual Rp and As for each filter. To find the ripple and attenuation values you should use freqz to output the frequency response h and frequency w values to a vector at enough points , say 1000, then use the min or max commands to find the min or max in the passband or stopband range in the frequency response. You may need to use commands to convert to dB. e. Plot the magnitude response (in dB) for all three filters on one plot and plot the phase response for all three filters on another plot ( title the graph, label axes, and use a legend to identity the filter )

PLEASE SOLVE USING MATLAB

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part a

MATLAB Code

clc;
clear all;
close all;

Wp = 0.45;
Ws = 0.5;
Rp = 0.5;
Rs = 60;

[N, Wn] = buttord(Wp, Ws, Rp, Rs);
[b, a] = butter(N, Wn);

fprintf('The order of the Butterworth filter to meet the given specifications is %d \n', N);

w = 0:pi/1000:pi;
H = freqz(b, a, w);

H_dB = 20*log10(abs(H));
H_phase = angle(H)*180/pi;


subplot(2,1,1)
plot(w/pi, H_dB, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Magnitude in dB');
title('Magnitude Response of the Butterworth Filter');

subplot(2,1,2)
plot(w/pi, H_phase, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Phase in degrees');
title('Phase Response of the Butterworth Filter');

After Execution, we get

In the command window, the order required is displayed

The order of the Butterworth filter to meet the given specifications is 51
>>

The frequency response plot obtained for the Butterworth Filter is as follows

Magnitude Response of the Butterworth Filter 100 -100 -200 -300 400 -500 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 Normalized Frequ

Part b

MATLAB Code

clc;
clear all;
close all;

Wp = 0.45;
Ws = 0.5;
Rp = 0.5;
Rs = 60;

[N, Wn] = cheb1ord(Wp, Ws, Rp, Rs);
[b, a] = cheby1(N, Rp, Wp);

fprintf('The order of the Chebyshev Type I filter to meet the given specifications is %d \n', N);

w = 0:pi/1000:pi;
H = freqz(b, a, w);

H_dB = 20*log10(abs(H));
H_phase = angle(H)*180/pi;


subplot(2,1,1)
plot(w/pi, H_dB, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Magnitude in dB');
title('Magnitude Response of the Chebyshev Type I Filter');

subplot(2,1,2)
plot(w/pi, H_phase, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Phase in degrees');
title('Phase Response of the Chebyshev Type I Filter');

After Execution, we get

In the command window, the order required is displayed

The order of the Chebyshev Type I filter to meet the given specifications is 16
>>

The frequency response plot obtained for the Chebyshev Type I Filter is as follows

Magnitude Response of the Chebyshev Type l Filter -100 -200 -300 400 -500 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 Normalized Freq

Part c

MATLAB Code

clc;
clear all;
close all;

Wp = 0.45;
Ws = 0.5;
Rp = 0.5;
Rs = 60;

[N, Wn] = ellipord(Wp, Ws, Rp, Rs);
[b, a] = ellip(N, Rp, Rs, Wp);

fprintf('The order of the Elliptic filter to meet the given specifications is %d \n', N);

w = 0:pi/1000:pi;
H = freqz(b, a, w);

H_dB = 20*log10(abs(H));
H_phase = angle(H)*180/pi;


subplot(2,1,1)
plot(w/pi, H_dB, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Magnitude in dB');
title('Magnitude Response of the Elliptic Filter');

subplot(2,1,2)
plot(w/pi, H_phase, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Phase in degrees');
title('Phase Response of the Elliptic Filter');

After Execution, we get

In the command window, the order required is displayed

The order of the Elliptic filter to meet the given specifications is 8
>>

The frequency response plot obtained for the Elliptic Filter is as follows

Magnitude Response of the Elliptic Filter -20 40 -60 -80 -100 -120 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 Normalized Frequency (

Part d

MATLAB Code

clc;
clear all;
close all;

Wp = 0.45;
Ws = 0.5;
Rp = 0.5;
Rs = 60;
w = 0:pi/1000:pi;


[Nb, Wn] = buttord(Wp, Ws, Rp, Rs);
[bb, ab] = butter(Nb, Wn);
Hb = freqz(bb, ab, w);


Nc = cheb1ord(Wp, Ws, Rp, Rs);
[bc, ac] = cheby1(Nc, Rp, Wp);
Hc = freqz(bc, ac, w);

Ne = ellipord(Wp, Ws, Rp, Rs);
[be, ae] = ellip(Ne, Rp, Rs, Wp);
He = freqz(be, ae, w);


wp_range = 0:pi/1000:0.45*pi;
ws_range = 0.5*pi:pi/1000:pi;

L1 = length(wp_range);
L2 = length(ws_range);

Hb_pb = Hb(1:L1);
Hb_pb_min = min(Hb_pb);
Rpb = 20*log10(abs(Hb_pb_min));

Hb_sb = Hb(L2:end);
Hb_sb_max = max(Hb_sb);
Rsb = 20*log10(abs(Hb_sb_max));

Hc_pb = Hc(1:L1);
Hc_pb_min = min(Hc_pb);
Rpc = 20*log10(abs(Hc_pb_min));

Hc_sb = Hc(L2:end);
Hc_sb_max = max(Hc_sb);
Rsc = 20*log10(abs(Hc_sb_max));


He_pb = He(1:L1);
He_pb_min = min(He_pb);
Rpe = 20*log10(abs(He_pb_min));

He_sb = He(L2:end);
He_sb_max = max(He_sb);
Rse = 20*log10(abs(He_sb_max));


fprintf('The order of the Butterworth filter to meet the given specifications is %d \n', Nb);
fprintf('The order of the Chebyshev Type I filter to meet the given specifications is %d \n', Nc);
fprintf('The order of the Elliptic filter to meet the given specifications is %d \n \n \n', Ne);


fprintf('The pass band ripple of the Butterworth filter designed is %f dB \n', Rpb);
fprintf('The stop band attenuation of the Butterworth filter designed is %f dB \n', Rsb);
fprintf('The pass band ripple of the Chebyshev Type I filter designed is %f dB \n', Rpc);
fprintf('The stop band attenuation of the Chebyshev Type I filter designed is %f dB \n', Rsc);
fprintf('The pass band ripple of the Elliptic filter designed is %f dB \n', Rpe);
fprintf('The stop band attenuation of the Elliptic filter designed is %f dB \n', Rse);

After executing, we get

The order of the Butterworth filter to meet the given specifications is 51
The order of the Chebyshev Type I filter to meet the given specifications is 16
The order of the Elliptic filter to meet the given specifications is 8


The pass band ripple of the Butterworth filter designed is -0.425802 dB
The stop band attenuation of the Butterworth filter designed is -60.000000 dB
The pass band ripple of the Chebyshev Type I filter designed is -0.500000 dB
The stop band attenuation of the Chebyshev Type I filter designed is -64.966806 dB
The pass band ripple of the Elliptic filter designed is -0.500000 dB
The stop band attenuation of the Elliptic filter designed is -60.000000 dB
>>

Part (e)

clc;
clear all;
close all;

Wp = 0.45;
Ws = 0.5;
Rp = 0.5;
Rs = 60;
w = 0:pi/1000:pi;


[Nb, Wn] = buttord(Wp, Ws, Rp, Rs);
[bb, ab] = butter(Nb, Wn);
Hb = freqz(bb, ab, w);
Hb_dB = 20*log10(abs(Hb));
Hb_phase = angle(Hb)*180/pi;


Nc = cheb1ord(Wp, Ws, Rp, Rs);
[bc, ac] = cheby1(Nc, Rp, Wp);
Hc = freqz(bc, ac, w);
Hc_dB = 20*log10(abs(Hc));
Hc_phase = angle(Hc)*180/pi;

Ne = ellipord(Wp, Ws, Rp, Rs);
[be, ae] = ellip(Ne, Rp, Rs, Wp);
He = freqz(be, ae, w);
He_dB = 20*log10(abs(He));
He_phase = angle(He)*180/pi;


plot(w/pi, Hb_dB, w/pi, Hc_dB, w/pi, He_dB, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Magnitude in dB');
title('Magnitude Response of the Filters Designed');
legend('Magnitude Response of Butterworth Filter', 'Magnitude Response of Chebyshve Type - I Filter', 'Magnitude Response of Elliptic Filter', 'Location', 'SouthWest');

figure
plot(w/pi, Hb_phase, w/pi, Hc_phase, w/pi, He_phase, 'linewidth',2);
grid
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Phase in degrees');
title('Phase Response of the Filters Designed');
legend('Phase Response of Butterworth Filter', 'Phase Response of Chebyshve Type - I Filter', 'Phase Response of Elliptic Filter', 'Location', 'SouthWest');

The plots obtained after execution

Magnitude Response of the Filters Designed 100 -100 -200 -300 400 Magnitude Response of Butterworth Filter Magnitude Response

Phase Response of the Filters Designed 200 150 100 50 -50 -100 -150 Phase Response of Butterworth Filter Phase Response of Ch

Add a comment
Know the answer?
Add Answer to:
2. Design a digital lowpass filter to meet the following specifications: passband edge = 0.45π stopband...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT