Design FIR Low Pass filter using I-type linear phase, according to the parameters as follow, by matlab code: omegap=0.2π,omegas=0.4π,A
时间: 2024-02-18 18:59:12 浏览: 106
Sure, here is the Matlab code for designing an I-type linear phase FIR low pass filter according to the given parameters:
```
% Define filter parameters
Fs = 1000; % Sampling frequency
Fpass = 0.2*pi*Fs/(2*pi); % Passband frequency
Fstop = 0.4*pi*Fs/(2*pi); % Stopband frequency
Ap = 0.1; % Passband ripple (dB)
Ast = 80; % Stopband attenuation (dB)
% Convert ripple and attenuation to linear scale
Rp = 10^(Ap/20);
Rs = 10^(Ast/20);
% Determine filter order
delta_w = Fstop - Fpass;
M = ceil((Ast-8)/(2.285*delta_w));
N = M + mod(M,2); % Ensure N is odd
% Design filter using firpm function
b = firpm(N, [0 Fpass Fstop Fs/2]/(Fs/2), [1 1 0 0], [Rp Rs]);
% Plot magnitude and phase response
freqz(b,1,Fs)
```
In this code, we first define the filter parameters including the sampling frequency, passband frequency, stopband frequency, passband ripple, and stopband attenuation. We then convert the ripple and attenuation from decibels to linear scale. The filter order is determined using the Kaiser formula with a modified scaling factor of 2.285. We ensure that the filter order is odd to ensure a linear phase response. The filter is designed using the firpm function with a window that transitions from 1 in the passband to 0 in the stopband. Finally, we plot the magnitude and phase response of the filter using the freqz function.
Note that the resulting filter coefficients are stored in the variable b, which can be used to filter a signal using the filter function in Matlab.
阅读全文