Main Content

digitalFilter

Digital filter

The Coefficients property has been replaced by the Numerator and Denominator properties. For more information, see Version History.

Description

Use designfilt to design and edit digitalFilter objects.

  • Use designfilt in the form d = designfilt(resp,Name,Value) to design a digital filter d with response type resp. Customize the filter using name-value arguments.

  • Use designfilt in the form designfilt(d) to edit an existing filter, d.

    Note

    This is the only way to edit an existing digitalFilter object. Its properties are otherwise read-only.

  • Use filter in the form dataOut = filter(d,dataIn) to filter a signal with a digitalFilter d. The input can be a double- or single-precision vector. It can also be a matrix with as many columns as there are input channels. You can also use the filtfilt and fftfilt functions with digitalFilter objects.

  • Use Filter Analyzer to visualize a digitalFilter.

Properties

expand all

Coefficients

Numerator coefficients, returned as one of these:

Denominator coefficients, returned as one of these:

Specifications

The Specification properties returned in a digitalFilter object depend on the filter response and design specified when creating the object using designfilt. All properties are read-only.

Filter Response

Filter response type, returned as one of these:

  • 'lowpass' for a lowpass filter

  • 'highpass' for a highpass filter

  • 'bandpass' for a bandpass filter

  • 'bandstop' for a bandstop filter

  • 'differentiator' for an FIR differentiator filter

  • 'hilbert' for an FIR Hilbert transformer filter

  • 'arbmag' for an FIR filter of arbitrary magnitude response

Impulse response type, returned as 'fir' or 'iir'.

Filter Design

For more information about filter design properties, see Sample Rate, Frequency Constraints, Filter Order, Magnitude Constraints, and Design Method.

Object Functions

Filtering

fftfiltFFT-based FIR filtering using overlap-add method
filter1-D digital filter
filtfiltZero-phase digital filtering
bandpassBandpass-filter signals
bandstopBandstop-filter signals
highpassHighpass-filter signals
lowpassLowpass-filter signals

Filter Analysis

doubleCast coefficients of digital filter to double precision
filt2blockGenerate Simulink filter block
filtordFilter order
firtypeType of linear phase FIR filter
freqzFrequency response of digital filter
grpdelayAverage filter delay (group delay)
impzImpulse response of digital filter
impzlengthImpulse response length
infoInformation about digital filter
isallpassDetermine whether filter is allpass
isdoubleDetermine if digital filter coefficients are double precision
isfirDetermine if digital filter has finite impulse response
islinphaseDetermine whether filter has linear phase
ismaxphaseDetermine whether filter is maximum phase
isminphaseDetermine whether filter is minimum phase
issingleDetermine if digital filter coefficients are single precision
isstableDetermine whether filter is stable
phasedelayPhase delay of digital filter
phasezPhase response of digital filter
singleCast coefficients of digital filter to single precision
ssConvert digital filter to state-space representation
stepzStep response of digital filter
tfConvert digital filter to transfer function
zerophaseZero-phase response of digital filter
zpkConvert digital filter to zero-pole-gain representation
zplaneZero-pole plot for discrete-time systems

Examples

collapse all

Design a lowpass IIR filter with order 8, passband frequency 35 kHz, and passband ripple 0.2 dB. Specify a sample rate of 200 kHz. Visualize the frequency response of the filter.

lpFilt = designfilt("lowpassiir",FilterOrder=8, ...
         PassbandFrequency=35e3,PassbandRipple=0.2, ...
         SampleRate=200e3);
freqz(lpFilt)

Figure contains 2 axes objects. Axes object 1 with title Phase, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Phase (degrees) contains an object of type line. Axes object 2 with title Magnitude, xlabel Normalized Frequency (\times\pi rad/sample), ylabel Magnitude (dB) contains an object of type line.

Use the filter you designed to filter a 1000-sample random signal.

dataIn = randn(1000,1);
dataOut = filter(lpFilt,dataIn);

Output the filter coefficients, expressed as cascaded transfer functions.

ctfNum = lpFilt.Numerator
ctfNum = 4×3

    0.2666    0.5333    0.2666
    0.1943    0.3886    0.1943
    0.1012    0.2023    0.1012
    0.0318    0.0636    0.0318

ctfDen = lpFilt.Denominator
ctfDen = 4×3

    1.0000   -0.8346    0.9073
    1.0000   -0.9586    0.7403
    1.0000   -1.1912    0.5983
    1.0000   -1.3810    0.5090

More About

expand all

References

[1] Lyons, Richard G. Understanding Digital Signal Processing. Upper Saddle River, NJ: Prentice Hall, 2004.

Version History

Introduced in R2014a

expand all