Contenuto principale

Highpass IIR

Design highpass infinite impulse response filter

Description

A highpass filter attenuates the energy of an input signal below a specified frequency threshold. An infinite impulse response (IIR) filter computes an output signal as a running weighted average of input samples and previous output values.

Signal Processing Toolbox™ provides different ways to design highpass IIR filters:

All of these methods return digitalFilter objects. If you have a DSP System Toolbox™ license, you can generate your design as a filter System object™ and include additional Design Method Options.

For other ways to design highpass IIR filters using MATLAB, see Other Highpass IIR Filter Design Functions.

Examples

expand all

To design the filter at the command line or in a script, use the designfilt function with "highpassiir" as the first argument. Use name-value arguments to specify your design further.

d = designfilt("highpassiir", ...  % Response type
    SampleRate=2000, ...           % Sample rate
    StopbandFrequency=400, ...     % Frequency constraints
    PassbandFrequency=550, ...
    StopbandAttenuation=25, ...    % Magnitude constraints
    PassbandRipple=5, ...
    DesignMethod="ellip", ...      % Design method
    MatchExactly="passband", ...   % Design method options
    ScaleSOS=true);
filterAnalyzer(d)

To design the filter using the Design Filter Live Editor task:

  1. Specify the filter:

    • Under Select filter response, select Highpass IIR.

    • Under Sample Rate, specify Frequency units as Hz and Input sample rate (Hz) as 2000.

    • Under Specify frequency parameters, specify a stopband frequency of 400 Hz and a passband frequency of 550 Hz.

    • Under Specify magnitude parameters, specify a stopband attenuation of 25 dB and a passband ripple of 5 dB.

    • Under Specify algorithm, select Elliptic. Under Specify algorithm options, specify that the design match the Passband exactly.

  2. The Live Editor task updates the filter automatically by default.

    Highpass IIR filter design using Live Editor task

To design the filter using the Filter Designer app:

  1. In the Response gallery of the Designer tab in the app toolstrip, select Highpass IIR.

  2. Specify the filter using the options in the Filter Parameters table:

    • In Design by, select Specification.

    • In Sample Rate, specify Frequency units as Hz and Input sample rate (Hz) as 2000.

    • Under Frequency Specifications, specify a stopband frequency of 400 Hz and a passband frequency of 550 Hz.

    • Under Magnitude Specifications, specify a stopband attenuation of 25 dB and a passband ripple of 5 Hz.

    • Under Algorithm, select Elliptic. Under Algorithm Options, specify that the design match the Passband exactly.

  3. In the Filter section of the Designer tab, click Update Filter.

    Highpass IIR filter design using Filter Designer app

  4. Export code to create your digital filter. On the toolstrip, click Export and select Generate MATLAB function > Digital Filter Object. The code appears in the editor.

    function designedFilter = highpassiir1filt
    
    designedFilter = designfilt('highpassiir', ...
        'StopbandFrequency',400,'PassbandFrequency',550, ...
        'StopbandAttenuation',25,'PassbandRipple',5, ...
        'SampleRate',2000,'DesignMethod','ellip', ...
        'MatchExactly','passband','ScaleSOS',true);
    
    end

Parameters

expand all

Design Method

Specify the algorithm to design the filter. The available design methods correlate with the set of design specifications that you choose.

Design the filter using the Butterworth algorithm. Butterworth filters have a smooth monotonic frequency response that is maximally flat in the passband. They trade rolloff steepness for flatness.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

Specify DesignMethod="butter".

In the Specify algorithm section of the task, set Design method to Butterworth.

In the Algorithm section of the filter parameters panel, set Design method to Butterworth.

The Butterworth design method supports these design parameter combinations.

Filter OrderFrequency SpecificationsMagnitude SpecificationsDesign Method OptionsDSP System Toolbox License Required
N/A

 

N/AN/A 

N/AN/A 

Design the filter using the Chebyshev type I algorithm. Chebyshev type I filters have a frequency response that is equiripple in the passband and maximally flat in the stopband. Their passband ripple increases with increasing rolloff steepness.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

Specify DesignMethod="cheby1".

In the Specify algorithm section of the task, set Design method to Chebyshev type I.

In the Algorithm section of the filter parameters panel, set Design method to Chebyshev type I.

The Chebyshev type I design method supports these design parameter combinations.

Filter OrderFrequency SpecificationsMagnitude SpecificationsDesign Method OptionsDSP System Toolbox License Required
N/A

 

N/A 

N/AN/A

N/A

Design the filter using the Chebyshev type II algorithm. Chebyshev type II filters have a frequency response that is maximally flat in the passband and equiripple in the stopband.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

Specify DesignMethod="cheby2".

In the Specify algorithm section of the task, set Design method to Chebyshev type II.

In the Algorithm section of the filter parameters panel, set Design method to Chebyshev type II.

The Chebyshev type II design method supports these design parameter combinations.

Design the filter using the elliptic algorithm. Elliptic filters have a frequency response that is equiripple in both passband and stopband.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

Specify DesignMethod="ellip".

In the Specify algorithm section of the task, set Design method to Elliptic.

In the Algorithm section of the filter parameters panel, set Design method to Elliptic.

The elliptic design method supports these design parameter combinations.

Design the filter using the least Pth-norm unconstrained optimization algorithm.

You must have a DSP System Toolbox license to use this design method.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

Specify DesignMethod="lpnorm".

In the Specify algorithm section of the task, set Design method to IIR least p-norm.

In the Algorithm section of the filter parameters panel, set Design method to IIR least p-norm.

The least Pth-norm method supports these design parameter combinations.

Sample Rate

Specify the filter sample rate as a positive scalar expressed in hertz.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • To specify a sample rate, use the SampleRate name-value argument and input a value in hertz.

  • To work with normalized frequencies, omit the sample rate.

In the Sample Rate section of the task:

  • To specify a sample rate, set Frequency units to Hz and type a value for Input sample rate (Hz).

  • To work with normalized frequencies, set Frequency units to Normalized.

In the Sample Rate section of the filter parameters panel:

  • To specify a sample rate, set Frequency units to Hz and type a value for Input sample rate (Hz).

  • To work with normalized frequencies, set Frequency units to Normalized.

Filter Order

Specify the filter order N as a positive integer. Some design methods let you specify the order. Others generate minimum-order designs, which are the shortest filters that satisfy the specified constraints.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

  • To specify a filter order, use the FilterOrder name-value argument and input a positive integer.

  • To use a minimum-order design, specify frequency and magnitude constraints accordingly.

In the Specify Filter Order section of the task:

  • To specify a filter order, set Order mode to Specify and enter a value for Order.

  • To use a minimum-order design, set Order mode to Minimum.

In the Filter Order section of the filter parameters panel:

  • To specify a filter order, set Order mode to Specify and enter a value for Order.

  • To use a minimum-order design, set Order mode to Minimum.

Specify the numerator order as a positive integer.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

  • Use the NumeratorOrder name-value argument. Input the value as a positive integer.

In the Specify Filter Order section of the task:

  • To specify a numerator order, set Order mode to Specify, select the Denominator order box, and enter a value for Numerator order.

In the Filter Order section of the filter parameters panel:

  • To specify a numerator order, set Order mode to Specify, select the Denominator order box, and enter a value for Numerator order.

Specify the denominator order as a positive integer.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App

  • Use the DenominatorOrder name-value argument. Input the value as a positive integer.

In the Specify Filter Order section of the task:

  • To specify a denominator order, set Order mode to Specify, select the Denominator order box, and enter a value for Denominator order.

In the Filter Order section of the filter parameters panel:

  • To specify a denominator order, set Order mode to Specify, select the Denominator order box, and enter a value for Denominator order.

Frequency Specifications

Specify the passband frequency as a positive scalar smaller than the Nyquist frequency. If you work with normalized frequencies, the Nyquist frequency is 1. If you specify a sample rate Fs, the Nyquist frequency is Fs/2.

The passband frequency is the lowest frequency for which the magnitude response of the filter is within an interval of width Passband Ripple from the reference value, usually 0 dB.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the PassbandFrequency name-value argument. Input the value as a positive scalar.

  • In the Specify Frequency Parameters section of the task, select a set of Frequency Constraints containing Passband frequency and enter a positive scalar as the value.

  • In the Frequency Specifications section of the filter parameters panel, select a set of Frequency Constraints containing Passband frequency and enter a positive scalar as the value.

Specify the stopband frequency as a positive scalar smaller than the Nyquist frequency. If you work with normalized frequencies, the Nyquist frequency is 1. If you specify a sample rate Fs, the Nyquist frequency is Fs/2.

The stopband frequency is the highest frequency for which the magnitude response of the filter is at least Stopband Attenuation dB lower than the reference value, usually 0 dB.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the StopbandFrequency name-value argument. Input the value as a positive scalar.

  • In the Specify Frequency Parameters section of the task, select a set of Frequency Constraints containing Stopband frequency and enter a positive scalar as the value.

  • In the Frequency Specifications section of the filter parameters panel, select a set of Frequency Constraints containing Stopband frequency and enter a positive scalar as the value.

Specify the half-power frequency as a positive scalar smaller than the Nyquist frequency. If you work with normalized frequencies, the Nyquist frequency is 1. If you specify a sample rate Fs, the Nyquist frequency is Fs/2.

The half-power frequency is the frequency at which the magnitude response of the filter is pow2db(1/2) = 10 log10½ = –3.01 dB below the reference value, usually 0 dB.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the HalfPowerFrequency name-value argument. Input the value as a positive scalar.

  • In the Specify Frequency Parameters section of the task, set Frequency Constraints to Half power (3dB) frequency and enter a positive scalar as the value.

  • In the Frequency Specifications section of the filter parameters panel, set Frequency Constraints to Half power (3dB) frequency and enter a positive scalar as the value.

Magnitude Specifications

Specify the passband ripple as a positive scalar in decibels.

The passband ripple measures the fluctuation of the passband gain of the filter about the reference value, usually 0 dB.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the PassbandRipple name-value argument. Input the value as a positive scalar in decibels.

  • In the Specify Magnitude Parameters section of the task, select a set of Magnitude Constraints containing Passband ripple (dB) and enter a positive scalar in decibels as the value.

  • In the Magnitude Specifications section of the filter parameters panel, select a set of Magnitude Constraints containing Passband ripple (dB) and enter a positive scalar in decibels as the value.

Specify the stopband attenuation as a positive scalar in decibels.

The stopband attenuation measures the extent by which the filter gain in the stopband is decreased in comparison to the reference value, usually 0 dB.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the StopbandAttenuation name-value argument. Input the value as a positive scalar in decibels.

  • In the Specify Magnitude Parameters section of the task, select a set of Magnitude Constraints containing Stopband attenuation (dB) and enter a positive scalar in decibels as the value.

  • In the Magnitude Specifications section of the filter parameters panel, select a set of Magnitude Constraints containing Stopband attenuation (dB) and enter a positive scalar in decibels as the value.

Design Method Options

Basic Options

Specify the band that the design must match exactly.

  • By default, the Butterworth and Chebyshev type II algorithms match the stopband exactly.

  • By default, the Chebyshev type I algorithm matches the passband exactly.

  • By default, the elliptic algorithm matches both the passband and the stopband exactly. This option is available only for the elliptic design method.

Advanced Options

Density of the frequency grid used by the Least Pth-Norm algorithm, specified as a positive scalar ≥ 10. The frequency grid has roughly (Density Factor × Filter Order)/(2 × Passband Frequency) frequency points. Increasing the density factor results in filters that more closely approximate an equiripple filter but take longer to compute.

You must have a DSP System Toolbox license to use this option. This parameter is available only in the designfilt function.

designfilt Function Design Filter Live Editor Task Filter Designer App
  • Use the DensityFactor name-value argument. Input the value as a positive scalar greater than 10.

N/A

N/A

Initial estimate of the filter denominator coefficients for the Least Pth-Norm algorithm, specified as a vector of size (N+1)-by-1, where N is the Filter Order that you specify.

You must have a DSP System Toolbox license to use this option. This parameter is available only in the designfilt function.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the InitialDenominator name-value argument. Input the value as a vector of size (N+1)-by-1, where N is the filter order.

N/A

N/A

Initial Pth norm used by the Least Pth-Norm algorithm, specified as a positive scalar. Starting the optimization with a smaller initial value aids in the convergence of the algorithm. For more information, see Least Pth-Norm Optimal IIR Filter Design (DSP System Toolbox).

You must have a DSP System Toolbox license to use this option. This parameter is available only in the designfilt function.

designfilt Function Design Filter Live Editor Task Filter Designer App
  • Use the InitialNorm name-value argument. Input the value as a positive scalar.

N/A

N/A

Initial estimate of the filter numerator coefficients for the Least Pth-Norm algorithm, specified as a vector of size (N+1)-by-1, where N is the Filter Order that you specify.

You must have a DSP System Toolbox license to use this option. This parameter is available only in the designfilt function.

designfilt Function Design Filter Live Editor Task Filter Designer App
  • Use the InitialNumerator name-value argument. Input the value as a vector of size (N+1)-by-1, where N is the filter order.

N/A

N/A

Maximum pole radius used by the Least Pth-Norm algorithm, specified as a scalar in the range (0,1]. This value indicates the maximum radius of each pole in the pole/zero plot of the designed filter.

You must have a DSP System Toolbox license to use this option. This parameter is available only in the designfilt function.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the MaxPoleRadius name-value argument. Input the value as a positive scalar less than or equal to 1

  • In the Specify Algorithm Options section of the task, specify Max pole radius as a positive scalar less than or equal to 1.

  • In the Algorithm Options section of the filter parameters panel, specify Max pole radius as a positive scalar less than or equal to 1.

L-infinity norm used by the Least Pth-Norm algorithm, specified as a positive scalar.

You must have a DSP System Toolbox license to use this option.

designfilt Function Design Filter Live Editor Task Filter Designer App
  • Use the Norm name-value argument. Input the value as a positive scalar.

  • In the Specify Algorithm Options section of the task, specify Norm as a positive scalar.

  • In the Algorithm Options section of the filter parameters panel, specify Norm as a positive scalar.

Passband optimization weight for a Least Pth-Norm design, specified as a positive scalar.

Weights are a way of specifying the relative importance of the passband ripple and the stopband attenuation in a filter design. By default, the passband and the stopband are equally weighted, each with unit weight. By increasing the passband weight, you can increase the passband ripple at the expense of increasing the stopband attenuation.

You must have a DSP System Toolbox license to use this option with some syntaxes.

designfilt Function Design Filter Live Editor Task Filter Designer App
  • Use the PassbandWeight name-value argument. Input the value as a positive scalar.

  • In the Specify Algorithm Options section of the task, specify Passband Weight as a positive scalar.

  • In the Algorithm Options section of the filter parameters panel, specify Passband Weight as a positive scalar.

Stopband optimization weight for a Least Pth-Norm design, specified as a positive scalar.

Weights are a way of specifying the relative importance of the passband ripple and the stopband attenuation in a filter design. By default, the passband and the stopband are equally weighted, each with unit weight. By increasing the stopband weight, you can increase the stopband attenuation at the expense of increasing the passband ripple.

You must have a DSP System Toolbox license to use this option with some syntaxes.

designfilt Function Design Filter Live Editor Task Filter Designer App
  • Use the StopbandWeight name-value argument. Input the value as a positive scalar.

  • In the Specify Algorithm Options section of the task, specify Stopband Weight as a positive scalar.

  • In the Algorithm Options section of the filter parameters panel, specify Stopband Weight as a positive scalar.

Option to scale the filter coefficients representing second-order sections (SOS), specified as a logical scalar. When you set this parameter to true, the SOS coefficients are scaled using L-infinity norm scaling, so that the filter has unit gain at zero frequency.

You must have a DSP System Toolbox license to use this option.

designfilt FunctionDesign Filter Live Editor TaskFilter Designer App
  • Use the ScaleSOS name-value argument. Input the value as true or false.

  • In the Specify Algorithm Options section of the task, select the Scale SOS coefficients box.

  • In the Algorithm Options section of the filter parameters panel, select the Scale SOS coefficients box.

More About

expand all