Напиши подробное решение номера 1, на английском, ...
Criado em: 1 de dezembro de 2025
Respondido usando GPT-5.1 Thinking por Chat01
Criado em: 1 de dezembro de 2025
Respondido usando GPT-5.1 Thinking por Chat01
Напиши подробное решение номера 1, на английском, код на матлабе.
Problem 1 is: design a Chebyshev analog low-pass filter with given specs and then obtain the digital filter via impulse invariance, then plot impulse and magnitude responses for both. (HW3_2025.pdf)
Below is a detailed solution in English plus ready-to-run MATLAB code at the end.
We first design the analog Chebyshev Type I low-pass filter, then convert it to a digital IIR filter by impulse invariance.
Use
In MATLAB we’ll store these as:
matlabFp = 18e6; % Hz Fs1 = 20e6; % Hz (stopband edge) Wp = 2*pi*Fp; % rad/s Ws = 2*pi*Fs1; % rad/s
Note: the ratio of stopband to passband edge (in rad/s or Hz) is the same:
A Chebyshev Type I lowpass filter has magnitude squared:
Where:
Passband ripple in dB is related to via:
For :
(We’ll let MATLAB compute this numerically for us.)
The stopband attenuation is:
For a lowpass with passband edge at , we usually normalize such that is at the passband edge and we compare .
The formula for the minimum Chebyshev order is:
Let
Then
Numerically (approximate):
So the analog Chebyshev filter will be order 20.
In practice, MATLAB can calculate and the cutoff frequency for us with cheb1ord.
We now design the analog lowpass with these specs:
matlabRp = 0.3; % passband ripple in dB Rs = 60; % stopband attenuation in dB [N, Wc] = cheb1ord(Wp, Ws, Rp, Rs, 's'); % analog (s-plane) design % N = filter order (should come out as 20) % Wc = cutoff rad/s (Chebyshev cutoff)
Then use cheby1 to get numerator and denominator of :
matlab[ba, aa] = cheby1(N, Rp, Wc, 'low', 's'); % analog Chebyshev Type I, lowpass
So the analog transfer function is:
where ba and aa store the coefficients of the numerator and denominator.
Let:
Impulse invariance defines the digital impulse response as:
This ensures that each analog pole maps to a digital pole
The corresponding digital transfer function can be found by a partial fraction expansion or, more conveniently, with MATLAB’s impinvar function:
matlab[bz, az] = impinvar(ba, aa, Fs);
This directly gives you the discrete-time filter:
Note: Impulse invariance preserves the shape of the impulse response (sampled) but causes aliasing in the frequency domain; here we assume that the analog filter is sufficiently attenuated above Nyquist (25 MHz) so that aliasing is not critical.
We can obtain for a selected time interval using Control System Toolbox:
matlabt_max = 10/Fp; % e.g. several periods of passband edge t = linspace(0, t_max, 2000); % time vector Ha_sys = tf(ba, aa); % continuous-time transfer function ha = impulse(Ha_sys, t); % analog impulse response
For the digital filter we use impz:
matlabN_imp = 200; % number of samples to show [hd, n] = impz(bz, az, N_imp); % digital impulse response
We then plot and compare:
Use freqs for continuous-time filters. To compare with the digital case we’ll plot Analog frequency in Hz rather than rad/s:
matlabw_max = 2*pi*25e6; % up to 25 MHz (Nyquist of digital system) w = linspace(0, w_max, 4096); % rad/s Ha_w = freqs(ba, aa, w); % analog frequency response fa = w / (2*pi); % Hz MagHa_dB = 20*log10(abs(Ha_w)); % magnitude in dB
Use freqz with sampling frequency Fs so the frequency axis is in Hz:
matlab[Hd_w, fd] = freqz(bz, az, 4096, Fs); % fd in Hz MagHd_dB = 20*log10(abs(Hd_w));
We can then plot both on the same figure (or separate figures) to compare magnitude responses as functions of frequency up to 25 MHz.
Below is a single self-contained MATLAB script that:
matlab%% Problem 1: Chebyshev LPF + Impulse Invariance clear; clc; close all; %% Given specifications Fp = 18e6; % passband edge frequency (Hz) Fs1 = 20e6; % stopband edge frequency (Hz) Rp = 0.3; % passband ripple (dB) Rs = 60; % stopband attenuation (dB) Fs = 50e6; % sampling frequency for digital filter (Hz) T = 1/Fs; % sampling period (s) % Analog radian frequencies Wp = 2*pi*Fp; % passband edge (rad/s) Ws = 2*pi*Fs1; % stopband edge (rad/s) %% 1) Analog Chebyshev Type I design % Determine filter order and cutoff [N, Wc] = cheb1ord(Wp, Ws, Rp, Rs, 's'); fprintf('Analog Chebyshev filter order N = %d\n', N); % Design analog Chebyshev Type I lowpass (s-domain) [ba, aa] = cheby1(N, Rp, Wc, 'low', 's'); % Analog transfer function H_a(s) Ha_sys = tf(ba, aa); % requires Control System Toolbox %% 2) Impulse invariance: analog -> digital % Obtain digital IIR filter using impulse invariance [bz, az] = impinvar(ba, aa, Fs); %% 3) Impulse responses % --- Analog impulse response --- t_max = 10/Fp; % choose a suitable time span t = linspace(0, t_max, 2000); % time vector ha = impulse(Ha_sys, t); % --- Digital impulse response --- N_imp = 200; % number of samples for impulse response [hd, n] = impz(bz, az, N_imp); % digital impulse response % Plot impulse responses figure; subplot(2,1,1); plot(t, ha, 'LineWidth', 1.2); grid on; xlabel('t (s)'); ylabel('h_a(t)'); title('Analog Impulse Response'); subplot(2,1,2); stem(n, hd, 'filled'); grid on; xlabel('n'); ylabel('h[n]'); title('Digital Impulse Response (Impulse Invariance)'); %% 4) Magnitude responses % --- Analog magnitude response --- w_max = 2*pi*25e6; % plot up to 25 MHz (Nyquist of digital system) w = linspace(0, w_max, 4096); % rad/s Ha_w = freqs(ba, aa, w); % analog freq response fa = w / (2*pi); % frequency axis in Hz MagHa_dB = 20*log10(abs(Ha_w)); % --- Digital magnitude response --- [Hd_w, fd] = freqz(bz, az, 4096, Fs); % fd in Hz MagHd_dB = 20*log10(abs(Hd_w)); % Plot magnitude responses figure; subplot(2,1,1); plot(fa/1e6, MagHa_dB, 'LineWidth', 1.2); grid on; xlabel('Frequency (MHz)'); ylabel('|H_a(j\Omega)| (dB)'); title('Analog Chebyshev LPF Magnitude Response'); xlim([0 25]); % show 0–25 MHz subplot(2,1,2); plot(fd/1e6, MagHd_dB, 'LineWidth', 1.2); grid on; xlabel('Frequency (MHz)'); ylabel('|H_d(e^{j\omega})| (dB)'); title('Digital IIR (Impulse Invariance) Magnitude Response'); xlim([0 25]); % 0–25 MHz (Nyquist)
If you’d like, I can also add comments showing how to extract and write down the difference equation of the resulting digital filter from the bz and az coefficients.
Warning: The output is not correct/robust. Coeffs of B(s)/A(s) are real, but B(z)/A(z) has complex
coeffs. Probable cause is rooting of high-order repeated poles in A(s).
B(z) and A(z) have been forced to be real using real(A(z)) and real(B(z)).
In impinvar (line 130)
In problem1 (line 30)