This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Designing Filters Using Command Line Functions

You can specify and design filters at the command line using designfilt. The use of designfilt provides a powerful and efficient way to specify and implement digital filters.

As an example, consider a lowpass filter for data sampled at 20 kHz. The desired passband frequency is 1 kHz with a stopband frequency of 1.2 kHz. Limit the passband ripple to 1 dB and require 60 dB of attenuation between the passband and stopband frequencies.

Fs = 20000;
Fp = 1000;
Fst = 1200;
Ap = 1;
Ast = 60;

Design an equiripple FIR filter and a Butterworth IIR filter.

FIR = designfilt('lowpassfir', ...
    'PassbandFrequency',Fp,'StopbandFrequency',Fst, ...
    'PassbandRipple',Ap,'StopbandAttenuation',Ast, ...

IIR = designfilt('lowpassiir', ...
    'PassbandFrequency',Fp,'StopbandFrequency',Fst, ...
    'PassbandRipple',Ap,'StopbandAttenuation',Ast, ...

Display the magnitude responses of the filters.

hfvt = fvtool(FIR,IIR);
axis([0 2 -70 10])

Was this topic helpful?