Documentation Center

  • Trial Software
  • Product Updates

Contents

dsp.FIRFilter System object

Package: dsp

Static or time-varying FIR filter

Description

The FIRFilter object filters each channel of the input using static or time-varying FIR filter implementations.

To filter each channel of the input:

  1. Define and set up your FIR filter. See Construction.

  2. 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.

Construction

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 variable-size input.

H = dsp.FIRFilter('PropertyName',PropertyValue, ...) returns an FIR filter system object, H, with each property set to the specified value.

Properties

Structure

Filter structure

Specify the filter structure.

You can specify the filter structure as one of | Direct form | Direct form symmetric | Direct form antisymmetric | Direct form transposed | Lattice MA |. The default is Direct form.

NumeratorSource

Source of filter coefficients

Specify the source of the filter coefficients as one of | Property | Input port |. The default is Property. When you specify Input port, the filter object updates the time-varying filter once every frame, when the FrameBasedProcessing property is true. When the FrameBasedProcessing property is false, it updates once every sample.

This applies when you set the Structure to Direct form | Direct form symmetric | Direct form antisymmetric | Direct form transposed.

ReflectionCoefficientsSource

Source of filter coefficients

Specify the source of the Lattice filter coefficients as one of | Property | Input port |. The default is Property. When you specify Input port, the filter object updates the time-varying filter once every frame, when the FrameBasedProcessing property is true. When the FrameBasedProcessing property is false, it updates once every sample.

This applies when you set the Structure to Lattice MA .

Numerator

Numerator coefficients

Specify the filter coefficients as a real or complex numeric row vector. This property applies when you set the NumeratorSource property to Property, and the Structure property is not set to Direct form, Direct form symmetric, Direct form antisymmetric, or Direct form transposed. The default is [0.5 0.5]. This property is tunable.

ReflectionCoefficients

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 Structure property to Lattice MA, and the ReflectionCoefficientsSource property to Property. The default is [0.5 0.5]. This property is tunable.

InitialConditions

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.

FrameBasedProcessing

Enable frame-based processing

Set this property to true to enable frame-based processing. Set this property to false to enable sample-based processing. The default is true.

 Fixed-Point Properties

Methods

cloneCreate static or time-varying FIR filter with same property values
freqzFrequency response
fvtoolOpen filter visualization tool
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
impzImpulse response
isLockedLocked status for input attributes and nontunable properties
phasezUnwrapped phase response
releaseAllow property value and input characteristics changes
resetReset internal states of FIR filter
stepFilter input with FIR filter object

More Analysis Methods for Filter System Objects.

Examples

  1. 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)

  2. 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            
        FrameBasedProcessing: true         
    
    

Algorithms

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.

Both this object and its corresponding block let you specify whether to process inputs as individual samples or as frames of data. The object uses the FrameBasedProcessing property. The block uses the Input processing parameter. See Set the FrameBasedProcessing Property of a System object for more information.

See Also

Was this topic helpful?