Professional Documents
Culture Documents
MEMBERS:
1. KELVIN NGATIA ENE212-0064/2019
2. LENNY KIBE ENE212-0066/2019
3. BRIAN LEMAYIAN ENE212-0076/2019
4. DAVID KINYANJUI ENE212-0080/2019
1. LAB 1
QUESTION 1
Matlab code
% Filter specifications
Wc = 40000; % Passband corner frequency in rad/s
Ws = 56000; % Stopband corner frequency in rad/s
Amax = 0.28029; % Maximum passband ripple in dB
Amin = 40; % Minimum stopband attenuation in dB
figure;
plot(omega, Tg);
grid on;
xlabel('Frequency (rad/s)');
ylabel('Group Delay');
title('Chebyshev Type I Filter Group Delay');
set(gca, 'FontName', fn, 'FontSize', fs);
xticks([0:10000:100000]);
output:
Verification:
QUESTION 2 – 6 marks
Code:
% Filter specifications
Amax = 0.01; % Maximum passband ripple in dB
Amin = 40; % Minimum stopband attenuation in dB
Wp = 2; % Passband corner frequency in rad/s
Ws = 3; % Stopband corner frequency in rad/s
mag_butter = 20*log10(abs(mag_butter));
mag_cheby1 = 20*log10(abs(mag_cheby1));
mag_cheby2 = 20*log10(abs(mag_cheby2));
mag_ellip = 20*log10(abs(mag_ellip));
phase_butter = rad2deg(phase_butter);
phase_cheby1 = rad2deg(phase_cheby1);
phase_cheby2 = rad2deg(phase_cheby2);
phase_ellip = rad2deg(phase_ellip);
% Plot magnitude responses on a logarithmic scale
lw = 2;
fs = 16;
fn = 'times';
figure;
semilogx(omega, mag_butter, 'b', 'LineWidth', lw);
hold on;
semilogx(omega, mag_cheby1, 'r', 'LineWidth', lw);
semilogx(omega, mag_cheby2, 'g', 'LineWidth', lw);
semilogx(omega, mag_ellip, 'm', 'LineWidth', lw);
grid on;
xlabel('Frequency (rad/s)');
ylabel('Magnitude (dB)');
title('Comparison of LP Filters: Butterworth, Chebyshev I, Chebyshev II, and Elliptic');
legend('Butterworth', 'Chebyshev I', 'Chebyshev II', 'Elliptic', 'Location', 'southwest');
set(gca, 'FontName', fn, 'FontSize', fs);
Output:
QUESTION 3 – 5 marks
Code:
% Given specifications
Amax = 0.28; % Maximum passband ripple (dB)
Amin = 60; % Minimum stopband attenuation (dB)
Fpass1 = 12; % First passband frequency (Hz)
Fstop1 = 25; % First stopband frequency (Hz)
Fstop2 = 32; % Second stopband frequency (Hz)
Fpass2 = 60; % Second passband frequency (Hz)
% Estimate the filter order and cutoff frequencies using the buttord function
[n, Wn] = buttord([Wpass1, Wpass2], [Wstop1, Wstop2], Amax, Amin, 's');
output:
2. LAB 2
QUESTION 1 – 15 marks
a.
% Filter specifications
Wc = 20000; % Passband corner frequency in rad/s
Ws = 62000; % Stopband corner frequency in rad/s
Amax = 0.5; % Maximum passband ripple in dB
Amin = 40; % Minimum stopband attenuation in dB
output:
We get :
T ladder
L1 = 2.503946e-02 C1 = 0
L2 = 0 C2 = 6.55542e-08
L3 = 8.102939e-02 C3 = 0
L4 = 0 C4 = 6.55542e-08
L5 = 2.503946e-02 C5 = 0
π ladder:
L1 = 0 C1 = 2.503946e-08
L2 = 6.55542e-02 C2 = 0
L3 = 0 C3 = 8.102939e-08
L4 = 6.55542e-02 C4 = 0
L5 = 0 C5 = 2.503946e-08
b.
% Given specifications
Wc = 22000; % Cutoff frequency in Hz
Ws = 28000; % Stopband edge frequency in Hz
r = 0.5; % Desired attenuation ripple
Amax = -10*log10(1-r^2); % Maximum passband ripple in dB
Amin = 40; % Minimum stopband attenuation in dB
Rs = 1000; % Source impedance in ohms
RL = 1000; % Load impedance in ohms
L' % Transpose of L
C' % Transpose of C
Wo' % Transpose of Wo
Output:
C1 = 9.076098e-08
L2 = 3.763656-02 C2 = 1.839124-08 w02=3.800927e+04
C3 = 10.17367-08
L4 = 2.464374e-02 C4 = 5.490668-08 w04 = 2.718530e+04
C5 = 6.953684-08