Package: dsp
Static or timevarying FIR filter
The FIRFilter
object filters each channel
of the input using static or timevarying FIR filter implementations.
To filter each channel of the input:
Define and set up your FIR filter. See Construction.
Call step
to filter each channel
of the input according to the properties of dsp.FIRFilter
.
The behavior of step
is specific to each object in
the toolbox.
H = dsp.FIRFilter
returns
a default FIR filter object, H
, which independently
filters each channel of the input over successive calls to the step
method,
using a specified FIR filter implementation. This System object™ supports
variablesize input.
H = dsp.FIRFilter('
returns an FIR filter system object, PropertyName
',PropertyValue
,
...)H
,
with each property set to the specified value.

Filter structure Specify the filter structure.
 

Source of filter coefficients Specify the source of the filter coefficients as one of  This applies when you set the  

Source of filter coefficients Specify the source of the Lattice filter coefficients as one
of  This applies when you set the  

Numerator coefficients Specify the filter coefficients as a real or complex numeric
row vector. This property applies when you set the  

Reflection coefficients of lattice filter structure Specify the reflection coefficients of a lattice filter as a
real or complex numeric row vector. This property applies when you
set the  

Initial conditions for the FIR filter Specify the initial conditions of the filter states. The number of states or delay elements equals the number of reflection coefficients for the lattice structure, or the number of filter coefficients–1 for the other direct form structures. You can specify the initial conditions as a scalar, vector, or matrix. If you specify a scalar value, the FIR filter object initializes all delay elements in the filter to that value. If you specify a vector whose length equals the number of delay elements in the filter, each vector element specifies a unique initial condition for the corresponding delay element. The object applies the same vector of initial conditions to each channel of the input signal. If you specify a vector whose length equals the product of the number of input channels and the number of delay elements in the filter, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel. If you specify a matrix with the same number of rows as the number of delay elements in the filter, and one column for each channel of the input signal, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel. The default is 0. 
clone  Create static or timevarying FIR filter with same property values 
freqz  Frequency response 
fvtool  Open filter visualization tool 
getNumInputs  Number of expected inputs to step method 
getNumOutputs  Number of outputs of step method 
impz  Impulse response 
isLocked  Locked status for input attributes and nontunable properties 
phasez  Unwrapped phase response 
release  Allow property value and input characteristics changes 
reset  Reset internal states of FIR filter 
step  Filter input with FIR filter object 
Use an FIR filter to apply a low pass filter to a waveform with two sinusoidal components:
t = (0:1000)'/8e3; xin = sin(2*pi*0.3e3*t)+sin(2*pi*3e3*t); hSR = dsp.SignalSource; hSR.Signal = xin; hLog = dsp.SignalSink; hFIR = dsp.FIRFilter; hFIR.Numerator = fir1(10,0.5); h = dsp.SpectrumAnalyzer('SampleRate',8e3,... 'PlotAsTwoSidedSpectrum',false,... 'OverlapPercent', 80, 'PowerUnits','dBW',... 'YLimits', [150 10]); while ~isDone(hSR) input = step(hSR); filteredOutput = step(hFIR,input); step(hLog,filteredOutput); step(h,filteredOutput) end filteredResult = hLog.Buffer; fvtool(hFIR,'Fs',8000)
Design an FIR filter as a System object.
N = 10;
Fc = 0.4;
B = fir1(N,Fc);
Hf1 = dsp.FIRFilter('Numerator',B);
fvtool(Hf1)
This can also be achieved by using fdesign
as
a constructor and design
to design
the filter.
N = 10; Fc = 0.4; Hf = fdesign.lowpass('N,Fc',N,Fc); D = design(Hf,'systemobject',true) fvtool(D);
D = System: dsp.FIRFilter Properties: Structure: 'Direct form' NumeratorSource: 'Property' Numerator: [1x11 double] InitialConditions: 0 Fixedpoint properties: FullPrecisionOverride: true CoefficientsDataType: 'Same word length as input'
This object implements the algorithm, inputs, and outputs described on the Discrete FIR Filter block reference page. The object properties correspond to the block parameters.