主要内容

Complex Lowpass FIR

R2026b

Design complex lowpass finite impulse response filter

Description

A lowpass filter attenuates the energy of an input signal above a specified frequency threshold. A finite impulse response (FIR) filter computes an output signal as a running weighted average of input samples. A complex filter is characterized by complex-valued coefficients and processes the input signal along positive and negative frequencies.

To design a Complex Lowpass FIR filter, specify combinations of the parameters in the diagram. Click a parameter for more information.

Signal Processing Toolbox™ provides different ways to design complex lowpass FIR 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 options.

For other ways to design complex lowpass FIR filters using MATLAB, see cfirpm.

Examples

expand all

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

d = designfilt("complexlowpassfir", ... % Response type
    SampleRate=2000, ...                % Sample rate
    FilterOrder=30, ...                 % Filter order
    PassbandFrequency1=-350, ...        % Frequency constraints
    PassbandFrequency2=500, ...
    TransitionWidth=100, ...
    StopbandWeight1=2, ...              % Design method options
    PassbandWeight=1, ...
    StopbandWeight2=2);
filterAnalyzer(d)

To design the filter using the Filter Designer app:

  1. In the Response gallery of the Designer tab in the app toolstrip, select Complex Lowpass FIR.

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

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

    • Under Filter Order, specify the Order as 30.

    • Under Frequency Specifications, specify:

      • Passband frequency 1 as -350 Hz

      • Passband frequency 2 as 500 Hz

      • Transition width as 100 Hz

    • Under Algorithm, select Equiripple. Under Algorithm Options, specify:

      • Stopband weight 1 as 2

      • Passband weight as 1

      • Stopband weight 2 as 2

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

    Complex lowpass FIR 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 = complexlowpassfir1filt
    
    designedFilter = designfilt('complexlowpassfir', ...
        'FilterOrder',30,'PassbandFrequency1',-350, ...
        'PassbandFrequency2',500,'TransitionWidth',100, ...
        'SampleRate',2000,'StopbandWeight1',2, ...
        'StopbandWeight2',2);
    
    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 Parks-McClellan algorithm. Equiripple filters have a frequency response that minimizes the maximum ripple magnitude over all bands.

designfilt FunctionFilter Designer App

Specify DesignMethod="equiripple"

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

The equiripple design method supports these design parameter combinations.

Sample Rate

The sample rate you specify sets the Nyquist frequency for the filter. If you specify a sample rate Fs in hertz, the Nyquist frequency is Fs/2. If you work with normalized frequencies, the Nyquist frequency is 1.

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

designfilt FunctionFilter 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 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 FunctionFilter 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 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.

Frequency Specifications

The lower stopband frequency is the highest frequency in the lower stopband region.

Specify the lower stopband frequency as a negative scalar whose absolute value is smaller than the Nyquist frequency. If you specify a sample rate Fs in hertz, the Nyquist frequency is Fs/2. If you work with normalized frequencies, the Nyquist frequency is 1.

designfilt FunctionFilter Designer App
  • Use the StopbandFrequency1 name-value argument. Input the value as a negative scalar.

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

The lower passband frequency is the lowest frequency in the passband region.

Specify the lower passband frequency as a negative scalar whose absolute value is smaller than the Nyquist frequency. If you specify a sample rate Fs in hertz, the Nyquist frequency is Fs/2. If you work with normalized frequencies, the Nyquist frequency is 1.

designfilt FunctionFilter Designer App
  • Use the PassbandFrequency1 name-value argument. Input the value as a negative scalar.

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

The higher passband frequency is the highest frequency in the passband region.

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

designfilt FunctionFilter Designer App
  • Use the PassbandFrequency2 name-value argument. Input the value as a positive scalar.

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

The higher stopband frequency is the lowest frequency in the higher stopband region.

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

designfilt FunctionFilter Designer App
  • Use the StopbandFrequency2 name-value argument. Input the value as a positive scalar.

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

The transition band separates the passband region from either stopband region.

Specify the width of the transition band as a positive scalar smaller than the Nyquist frequency. If you specify a sample rate Fs in hertz, the Nyquist frequency is Fs/2. If you work with normalized frequencies, the Nyquist frequency is 1.

designfilt FunctionFilter Designer App
  • Use the TransitionWidth name-value argument. Input the value as a positive scalar.

  • In the Frequency Specifications section of the filter parameters panel, set Transition Width by entering a positive scalar as the value.

Design Method Options

Basic Options

Lower stopband optimization weight for an Equiripple design, specified as a positive scalar.

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

designfilt FunctionFilter Designer App
  • Use the StopbandWeight1 name-value argument. Input the value as a positive scalar.

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

Passband optimization weight for an Equiripple design, specified as a positive scalar.

Weights let you specify 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 decrease the passband ripple at the expense of decreasing stopband attenuation.

designfilt FunctionFilter Designer App
  • Use the PassbandWeight name-value argument. Input the value as a positive scalar.

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

Higher stopband optimization weight for an Equiripple design, specified as a positive scalar.

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

designfilt FunctionFilter Designer App
  • Use the StopbandWeight2 name-value argument. Input the value as a positive scalar.

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