Use the FIR filter and the sampling device to study both of these MATLAB implementations:
FIR Filter:
The key word of FIR filter on MATLAB is Fir1
In the Command window, enter help Fir1 to appear in the helper Documentation:
>> help Fir1
Fir1 FIR filter design using the Window method. fir Filter Use window Number method Design
B = Fir1 (n,wn) designs an N ' th order lowpass FIR digital filter B = Fir1 (N,WN) This is the design of an N-order low-pass filter
and returns the filter coefficients in length n+1 vect or B. with one n+ Form 1-Order vector return filter factor
The cut-off frequency WN must be between 0 < WN < 1.0, with 1.0 &NBSP ; cutoff frequency wn between 0~1
corresponding to half the sample rate. The filter B is real and 1.0 the deadline Frequency is half sample rate
has linear phase. The normalized gain of the filter at Wn are so that the filters B is real and linear phase
-6 DB. The gain at the cutoff frequency is -6db
B = Fir1 (n,wn, ' high ') designs an N ' th order highpass filter. B = Fir1 (n,wn, ' high ') produces an N-order high pass filter
You can also use B = Fir1 (n,wn, "low") to design a lowpass filter. B = Fir1 (n,wn, ' low ') can produce N-order lowpass filters
If WN is a two-element vector, wn = [W1 W2], FIR1 returns an If WN (WN = [W1 W2]) is a two-ary vector, the FIR1 function returns an n-order bandpass Filter
Order N bandpass filter with passband W1 < W < W2. You can pass band is W1 to W2, B = Fir1 (n,wn, ' bandpass ') used to produce bandpass filters
Also specify B = Fir1 (n,wn, ' bandpass '). If Wn = [W1 W2], B = Fir1 (n,wn, ' stop ') produces a band resistor
B = Fir1 (n,wn, ' Stop ') would design a bandstop filter.
If the WN is a multi-element vector, if the WN is a multiple vectors
Wn = [W1 W2 W3 W4 W5 ... WN], such as WN = [W1 W2 W3 W4 W5 ... WN],
Fir1 returns an order N multiband filter with bandsFir1 function produces a multiband? Filter
0 < W < W1, W1 < W < W2, ..., WN < W < 1. 0 < W < W1, W1 < W < W2, ..., WN < W < 1.
B = Fir1 (n,wn, ' DC-1 ') makes the first band a passband. B = Fir1 (n,wn, ' DC-1 ') indicates that the first band is a pass band
B = Fir1 (n,wn, ' DC-0 ') makes the first band a stopband. B = Fir1 (n,wn, ' DC-1 ') indicates that the first band is a resistive band
B = Fir1 (n,wn,win) designs an n-th order FIR filter usingB = Fir1 (N,wn,win), WIN is a vector of n+1-length windows, resulting in an N-order impulse response
The n+1 length vector WIN to window the impulse response.
If empty or omitted, Fir1 uses a Hamming window of length n+1. If there is no parameter, the WIN,FIR1 function defaults to the Hamming window with length n+1
For a complete list of available Windows, see the "Help for the" view window function for more win knowledge
WINDOW function. KAISER and Chebwin can be specified with an to add window functions like this
Optional trailing argument. For example, B = Fir1 (N,wn,kaiser (n+1,4))
Uses a Kaiser window with beta=4. B = Fir1 (n,wn, ' High ', Chebwin (n+1,r))
Uses a Chebyshev window with R decibels of relative sidelobe
Attenuation.
For filters with a gain and than zero at FS/2, e.g., highpass
and bandstop filters, N must be even. Otherwise, N'll be
incremented by one. The the window length should be
Specified as n+2.
By default, the filter was scaled so the center of the first pass band
Have magnitude exactly one after windowing. Use a trailing ' noscale '
argument to prevent this scaling, e.g. B = Fir1 (n,wn, ' Noscale '),
b = Fir1 (N,wn, ' High ', ' Noscale '), B = Fir1 (N,wn,wind, ' Noscale '). You
can also specify the scaling explicitly, e.g. FIR1 (n,wn, ' scale '), etc.
% Example 1:
% Design a 48th-order FIR bandpass filter with Passband
% 0.35 <= W <= 0.65.
b = Fir1 (48,[0.35 0.65]); % window-based FIR Filter Design
FREQZ (b,1,512)% Frequency response of filter
% Example 2:
% The Chirp.mat file contains a signal, Y, that have most of its power
% above Fs/4, or half the Nyquist frequency. Design a 34th-order FIR
% highpass filter to attenuate the components of the signal below
% FS/4. Use a cutoff frequency of 0.48 and a Chebyshev windows with
% of DB of Ripple.
Load chirp; % Load data (y and Fs) into workspace
y = y + 0.5*rand (size (y)); % Adding Noise
b = Fir1 (34,0.48, ' High ', Chebwin (35,30)); % FIR Filter Design
FREQZ (b,1,512); % Frequency response of filter
Output = Filtfilt (b,1,y); % Zero-phase Digital filtering
Figure
Subplot (211); Plot (y, ' B '); Title (' Original Signal ')
Subplot (212); Plot (output, ' G '); Title (' Filtered Signal ')
See also Kaiserord, FIRCLS1, Fir2, Firls, Fircls, cfirpm,
firpm, FREQZ, Filter, window, designfilt.
Dabi-matlab-Common Knowledge Review