Main Content

digitalFilter

Digital filter

Description

Usedesignfiltto design and editdigitalFilterobjects.

  • Usedesignfiltin the formd = designfilt(resp,Name,Value)to design a digital filter,d, with response typeresp. Customize the filter further usingName,Valuepairs.

  • Usedesignfiltin the formdesignfilt(d)to edit an existing filter,d.

    Note

    This is the only way to edit an existingdigitalFilterobject. Its properties are otherwise read-only.

  • Usefilterin the formdataOut = filter(d,dataIn)过滤的一个信号digitalFilterd. 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.

  • UseFVToolto visualize adigitalFilter.

  • These functions takedigitalFilterobjects as input.

Object Functions

Filtering

Function Description

fftfilt

Filters a signal with adigitalFilterusing an FFT-based overlap-add method

filter

Filters a signal using adigitalFilter

filtfilt

Performs zero-phase filtering of a signal with adigitalFilter

Filter Analysis

Function Description

double

Casts the coefficients of adigitalFilterto double precision

filt2block

Generates a Simulink®filter block corresponding to adigitalFilter

filtord

Returns the filter order of adigitalFilter

firtype

Returns the type (1, 2, 3, or 4) of an FIRdigitalFilter

freqz

Returns or plots the frequency response of adigitalFilter

FVTool

Opens the Filter Visualization Tool and displays the magnitude response of adigitalFilter

grpdelay

Returns or plots the group delay response of adigitalFilter

impz

Returns or plots the impulse response of adigitalFilter

impzlength

Returns the length of the impulse response of adigitalFilter, whether actual (for FIR filters) or effective (for IIR filters)

info

Returns a character array with information about adigitalFilter

isallpass

Returnstrueif adigitalFilteris allpass

isdouble

Returnstrueif the coefficients of adigitalFilterare double precision

isfir

Returnstrueif adigitalFilterhas a finite impulse response

islinphase

Returnstrueif adigitalFilterhas linear phase

ismaxphase

Returnstrueif adigitalFilteris maximum phase

isminphase

Returnstrueif adigitalFilteris minimum phase

issingle

Returnstrueif the coefficients of adigitalFilterare single precision

isstable

Returnstrueif adigitalFilteris stable

phasedelay

回报或情节相位延迟response of adigitalFilter

phasez

Returns or plots the (unwrapped) phase response of adigitalFilter

single

Casts the coefficients of adigitalFilterto single precision

ss

Returns the state-space representation of adigitalFilter

stepz

Returns or plots the step response of adigitalFilter

tf

Returns the transfer function representation of adigitalFilter

zerophase

Returns or plots the zero-phase response of adigitalFilter

zpk

Returns the zero-pole-gain representation of adigitalFilter

zplane

Displays the poles and zeros of the transfer function represented by adigitalFilter

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 magnitude response of the filter.

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

Figure Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects 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 second-order sections.

sos = lpFilt.Coefficients
sos =4×60.2666 0.5333 0.2666 1.0000 -0.8346 0.9073 0.1943 0.3886 0.1943 1.0000 -0.9586 0.7403 0.1012 0.2023 0.1012 1.0000 -1.1912 0.5983 0.0318 0.0636 0.0318 1.0000 -1.3810 0.5090
Introduced in R2014a