Low Pass Filter Design in MATLAB -MATLAB and Simulink - MathWorks Germany (2023)

Open live script

This example shows how to design low pass filters. The example highlights some of the most commonly used command line tools in the DSP System Toolbox™. Alternatively, you can use the Filter Builder app to implement all of the layouts presented here. For more design options, seeLow pass FIR filter design.


When designing a low pass filter, the first choice you must make is to design an FIR or IIR filter. You typically choose FIR filters when a linear phase response is important. FIR filters also tend to be preferred for fixed-point implementations because they tend to be more resistant to quantization effects. FIR filters are also used in many high-speed implementations like FPGAs or ASICs because they are suitable for pipelines. IIR filters (particularly biquad filters) are used in applications (such as audio signal processing) where phase linearity is not a concern. IIR filters are generally more computationally efficient in the sense that they can meet design specifications with fewer coefficients than FIR filters. IIR filters also tend to have a shorter transient response and a shorter group delay. However, the use of multirate and minimum phase designs can result in FIR filters comparable to IIR filters in terms of group delay and computational efficiency.

FIR Low Pass Projects - Specifying Filter Order

There are many practical situations in which you must specify the filter order. One such case is if you are targeting hardware that has restricted the filter order to a specific number. Another common scenario is when you have calculated the available computational budget (MIPS) for your deployment and this gives you a limited filter order. FIR design functions in the signal processing toolbox (includingfour1,business, youchildren) are all capable of designing low-pass filters with a specific order. In the DSP system toolbox, the preferred function for low-pass FIR filter design with a specific order isfirceqrip. This function designs ideal equi-ripple low-pass/high-pass FIR filters with specified passband/stopband ripple values ​​and with a specified passband edge frequency. The stopband threshold frequency is determined as a result of the design.

Design a low-pass FIR filter for data sampled at 48 kHz. The passband edge frequency is 8 kHz. The passband ripple is 0.01 dB and the stopband attenuation is 80 dB. Restrict the filter order to 120.

n = 120; Fs = 48e3; Fp = 8e3; Ap = 0,01; ast = 80;

Find the maximum deviation for the passband and bandgap waveforms in linear units.

Rp = (10^(Ap/20) - 1)/(10^(Ap/20) + 1); First = 10^(-Ast/20);

Design the filter usingfirceqripand look at the magnitude frequency response.

NUM = firceqrip(N,Fp/(Fs/2),[Rp Rst],'ticket');fvherramienta(NUM,'fs',Fs)

Low Pass Filter Design in MATLAB-MATLAB and Simulink- MathWorks Germany (1)

The resulting bandgap edge frequency is approximately 9.64 kHz.

Minimum Order Projects

Another design function for optimal equiripple filters isfirgr.firgrYou can design a filter that meets passband/stopband ripple restrictions as well as a specified transition width with the smallest possible filter order. For example, if the bandgap cutoff frequency is specified as 10 kHz, the resulting filter will have an order of 100 instead of the order 120 filter designed withfirceqrip. The lowest filter order results from the highest transition band.

Specify the cutoff frequency of the 10 kHz cutoff band. Get a lower-order FIR filter with 0.01 dB passband ripple and 80 dB stopband attenuation.

Fst = 10e3; NumMin = firgr('the minimum order',[0 Fp/(Fs/2) Fst/(Fs/2) 1],...[1 1 0 0],[Rp,Rst]);

Plot the magnitude frequency responses for the lowest order FIR filter obtained withfirgrand the 120 order filter designed withfirceqrip. The minimum-order design results in a 100th-th filter. The transition region of the 120th-th filter is, as expected, narrower than that of the 100th-th filter.

hvft = fvtool(NUM,1,NumMin,1,'fs',Fs);legend(hvft,'N = 120','N = 100')

data filtering

To apply the filter to the data, you can use thefiltercommand or you can usedsp.FIRFilter.dsp.FIRFilterhas the advantage of managing state when running in a loop.dsp.FIRFilterit also has fixed-point capabilities and supports C code generation, HDL code generation, and optimized code generation for ARM® Cortex® M and ARM Cortex A.

Filter 10 seconds of white noise with zero mean and unity standard deviation into frames of 256 samples with the 120th order FIR low-pass filter. View the result on a spectrum analyzer.

LP_FIR = dsp.FIRFilter('Numerator',NUM);SA_FIR = spectrum analyzer('Sampling rate',Fs);ticwhiletoc < 10 x = randn(256,1); y = LP_FIR(x); stage(SA_FIR,y);finrelease (SA_FIR)

Low Pass Filter Design in MATLAB-MATLAB and Simulink- MathWorks Germany (3)


dsp.LowpassFilteris an alternative to usingfirceqripyfirgrtogether withdsp.FIRFilter. Basically,dsp.LowpassFilterIt condenses the two-step process into one.dsp.LowpassFilterprovides the same benefits asdsp.FIRFilterit provides in terms of fixed point support, C code generation support, HDL code generation support and ARM Cortex code generation support.

Design a low-pass FIR filter for data sampled at 48 kHz. The passband edge frequency is 8 kHz. The passband ripple is 0.01 dB and the stopband attenuation is 80 dB. Restrict the filter order to 120. Create adsp.FIRFilterbased on your specifications.

LP_FIR = dsp.LowpassFilter('Sampling rate',F,... 'DesignForMinimumOrder',FALSE,'Filter order',NORTE,... 'bandpass frequency',Fp,... 'PassbandRipple',Ap,'Interrupt Bandwidth Attenuation',ast);

The coefficients inLP_FIRare equal to the coefficients ofNUMBER.

NUM_LP = tf(LP_FIR);

You can useLP_FIRto filter the data directly, as shown in the example above. You can also analyze the filter using FVTool or measure the response usingmeasure.


Low Pass Filter Design in MATLAB-MATLAB and Simulink- MathWorks Germany (4)

measure (LP_FIR)
ans = Sampling rate: 48 kHz Passband edge: 8 kHz 3 dB point: 8.5843 kHz 6 dB point: 8.7553 kHz Stopband edge: 9.64 kHz Passband ripple: 0.01 dB Band stopped Caution. : 79.9981 dB Transition Width: 1.64 kHz

Minimum order layouts with dsp.LowpassFilter

You can usedsp.LowpassFilterto design minimum order filters and usemeasureto verify that the design meets the prescribed specifications. The filter order is again 100.

LP_FIR_minOrd = dsp.LowpassFilter('Sampling rate',F,... 'DesignForMinimumOrder',TRUE,... 'bandpass frequency',Fp,... 'Stop band frequency',First,... 'PassbandRipple',Ap,... 'Interrupt Bandwidth Attenuation',Ast);medida(LP_FIR_minOrd)
ans = Sampling rate: 48 kHz Passband threshold: 8 kHz 3 dB point: 8.7136 kHz 6 dB point: 8.922 kHz Stopband threshold: 10 kHz Passband ripple: 0.0098641 dB Stop the band's attention. : 80.122 dB Transition Width: 2 kHz
Nlp = order (LP_FIR_minOrd)
pnl = 100

IIR filter design

Elliptic filters are the IIR counterpart of the optimal equiripple FIR filters. Consequently, you can use the same specifications to design elliptical filters. The filter order obtained for an IIR filter is much smaller than the corresponding FIR filter order.

Design an elliptical filter with the same sample rate, cutoff frequency, passband ripple restriction, and stopband attenuation as the 120th order FIR filter. Reduce the filter order for the elliptical filter to 10.

N = 10;LP_IIR = dsp.FiltroPasoBajo('Sampling rate',F,... 'Filter type','IRI',... 'DesignForMinimumOrder',FALSE,... 'Filter order',NORTE,... 'bandpass frequency',Fp,... 'PassbandRipple',Ap,... 'Interrupt Bandwidth Attenuation',ast);

Compare the FIR and IIR designs. Calculate the cost of the two implementations.

hfvt = fvtool(LP_FIR,LP_IIR,'fs',Fs);legend(hfvt,'FOR Equironda, N = 120',... 'Elliptic IIR, N = 10');

Low Pass Filter Design in MATLAB-MATLAB and Simulink- MathWorks Germany (5)

cost_FIR = cost(LP_FIR)
cost_FIR =structure with fields:Numerical Coefficients: 121 Numerical States: 120 Multiplications by Input Sample: 121 Additions by Input Sample: 120
custo_IIR = custo(LP_IIR)
custo_IIR =structure with fields:Numerical coefficients: 25 Numerical states: 20 Multiplications per input sample: 25 Additions per input sample: 20

FIR and IIR filters have responses of similar magnitude. The cost of the IIR filter is about 1/6 of the cost of the FIR filter.

Running IIR Filters

The IIR filter is designed as a bisquare filter. To apply the filter to the data, use the same commands as for the FIR case.

Filter 10 seconds of white Gaussian noise with zero mean and unity standard deviation into 256-sample frames with the 10th-order IIR low-pass filter. View the result on a spectrum analyzer.

SA_IIR = spectrum analyzer ('Sampling rate',Fs);ticwhiletoc < 10 x = randn(256,1); y = LP_IIR(x); SA_IIR(s);finrelease (SA_IIR)

Low Pass Filter Design in MATLAB-MATLAB and Simulink- MathWorks Germany (6)

Variable Bandwidth FIR and IIR Filters

You can also create filters that let you change the cutoff frequency at runtime.dsp.VariableBandwidthFIRFilterydsp.VariableBandwidthIIRFiltercan be used for these cases.

related topics

  • Filter frames from a noisy sine wave signal in MATLAB
  • Low pass IIR filter design in Simulink
  • Adjustable low-pass filtering of noisy input in Simulink
  • Multirate filtering in MATLAB and Simulink

open example

You have a modified version of this example. Would you like to open this example with your changes?


You clicked on a link that corresponds to this MATLAB command:


Run the command by typing in the MATLAB command window. Web browsers do not support MATLAB commands.

Low Pass Filter Design in MATLAB-MATLAB and Simulink- MathWorks Germany (7)

Choose a site to get translated content where available and see local events and offers. Depending on your location, we recommend that you select:.

You can also select a site from the list below:


  • Latin America(Spanish)
  • Canada(English)
  • USA(English)


  • Belgium(English)
  • Denmark(English)
  • Germany(German)
  • spain(Spanish)
  • Finland(English)
  • France(French)
  • Ireland(English)
  • Italy(Italian)
  • Luxembourg(English)
  • Netherlands(English)
  • Norway(English)
  • Austria(German)
  • Portugal(English)
  • Sweden(English)
  • Swiss
    • German
    • English
    • French
  • United Kingdom(English)

asian pacific

Contact your local office

Top Articles
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated: 05/05/2023

Views: 6190

Rating: 4.1 / 5 (62 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.