Contents

dsp.VariableBandwidthFIRFilter System object

Package: dsp

Variable bandwidth FIR filter

Description

The VariableBandwidthFIRFilter object filters each channel of the input using FIR filter implementations. It does so while having the capability of tuning the bandwidth. This filter supports double and single precision inputs.

To filter each channel of the input:

  1. Define and set up your variable bandwidth FIR filter. See Construction.

  2. Call step to filter each channel of the input according to the properties of dsp.VariableBandwidthFIRFilter. The behavior of step is specific to each object in the toolbox.

Construction

HFIR = dsp.VariableBandwidthFIRFilter returns a System object™, HFIR, which independently filters each channel of the input over successive calls to the step method. This System object uses a specified FIR filter implementation. The filter's cutoff frequency may be tuned during the filtering operation. The variable bandwidth FIR filter is designed using the window method.

HFIR = dsp.VariableBandwidthFIRFilter('PropertyName',PropertyValue, ...) returns a variable bandwidth FIR filter System object, HFIR, with each property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

Properties

SampleRate

Input sample rate

Specify the sampling rate of the input in Hertz as a finite numeric scalar. The default is 44.1 kHz. This property is nontunable.

FilterType

Filter type

Specify the type of the filter as one of 'Lowpass' | 'Highpass' | 'Bandpass' | 'Bandstop'. The default is 'Lowpass'. This property is nontunable.

FilterOrder

FIR filter order

Specify the order of the FIR filter as a positive integer scalar. The default is 30. This property is nontunable.

Window

Window function

Specify the window function used to design the FIR filter as one of 'Hann' | 'Hamming' | 'Chebyshev' | 'Kaiser'. The default is 'Hann'. This property is nontunable.

KaiserWindowParameter

Kaiser window parameter

Specify the Kaiser window parameter as a real scalar. This property applies when you set the window property to 'Kaiser'. The default is 0.5. This property is nontunable.

CutoffFrequency

Filter cutoff frequency

Specify the filter cutoff frequency in Hz as a real, positive scalar, smaller than the SampleRate/2. This property applies if you set the FilterType property to 'Lowpass' or 'Highpass'. The default is 512 Hz. This property is tunable.

CenterFrequency

Filter center frequency

Specify the filter center frequency in Hz as a real, positive scalar, smaller than SampleRate/2. This property applies when you set the FilterType property to 'Bandpass' or 'Bandstop'. The default is 11025 Hz. This property is tunable.

Bandwidth

Filter bandwidth

Specify the filter bandwidth in Hertz as a real, positive scalar, smaller than SampleRate/2. This property applies if you set the FilterType property to 'Bandpass' or 'Bandstop'. The default is 7680 Hz. This property is tunable.

SidelobeAttenuation

Chebyshev window sidelobe attenuation

Specify the Chebyshev window attenuation as a real, positive scalar in decibels (dB). This property applies if you set the Window property to 'Chebyshev'. The default is 60 dB. This property is nontunable.

Methods

cloneCreate variable bandwidth FIR filter with same property values
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset internal states of variable bandwidth FIR filter
stepFilter signal using variable bandwidth algorithm

More Analysis Methods for Filter System Objects.

Examples

expand all

Filtering through a variable bandwidth bandpass FIR filter

This example shows you how to tune the center frequency and the bandwidth of the FIR filter.

    Fs = 44100; % Input sample rate
    % Define a bandpass variable bandwidth FIR filter:
    hfir = dsp.VariableBandwidthFIRFilter('FilterType','Bandpass',...
                                          'FilterOrder',100,...
                                          'SampleRate',Fs,...
                                          'CenterFrequency',1e4,...
                                          'Bandwidth',4e3);
    htfe = dsp.TransferFunctionEstimator('FrequencyRange','onesided');
    hplot = dsp.ArrayPlot('PlotType','Line',...
                          'XOffset',0,...
                          'YLimits',[-120 5], ...
                          'SampleIncrement', 44100/1024,...
                          'YLabel','Frequency Response (dB)',...
                          'XLabel','Frequency (Hz)',...
                          'Title','System Transfer Function');
    FrameLength = 1024;
    hsin = dsp.SineWave('SamplesPerFrame',FrameLength);
    for i=1:500
       % Generate input
       x = step(hsin) + randn(FrameLength,1);
       % Pass input through the filter
       y = step(hfir,x);
       % Transfer function estimation
       h = step(htfe,x,y);
       % Plot transfer function
       step(hplot,20*log10(abs(h)))
       % Tune bandwidth and center frequency of the FIR filter
       if (i==250)
          hfir.CenterFrequency = 5000;
          hfir.Bandwidth = 2000;
       end
    end

Algorithms

FIR Transformations

All transformations assume a lowpass filter of length 2N+1.

Lowpass to Lowpass

Consider an ideal lowpass brickwall filter with normalized cutoff frequency ωc1. By taking the inverse Discrete Fourier Transform of the ideal frequency response, and clipping the resulting sequence to length 2N+1, the impulse response is:

for n=0hLP(n)=ωcπ.w(0)for 1|n|NhLP(n)=sin(ωcn)πn.w(n)

where w(n) is the window vector. The lowpass filter coefficients are tuned to a new cutoff frequency ωc2 as follows:

for n=0hLP(n)=ωc2π.ω(0)for 1  |n|  NhLP(n)=sin(ωc2n)πn.ω(n)

There is no need to recompute the window every time you tune the cutoff frequency.

Lowpass to Highpass

Assuming a lowpass filter with normalized 6–dB cutoff frequency ωc, a highpass filter with the same cutoff frequency can be obtained by taking the complementary of the lowpass frequency response: HHP(e) = 1 — HLP(e)

Taking the inverse discrete Fourier transform of the above response, we get the following highpass filter coefficients:

for n=0hhp(n)=1hLP(n)for 1 |n|  Nhhp(n)=hLP(n)

Lowpass to Bandpass

A bandpass filtered centered at frequency ω0 can be obtained by shifting the lowpass response:

HBP(e) = HLP(ej(ω–ω0)) + HLP(ej(ω–ω0))

The bandwidth of the resulting bandpass filter is 2ωc, as measured between the two cutoff frequencies of the bandpass filter. The equivalent bandpass filter coefficients are then:

hBP(n)=(ejω0n+ejω0n)hLP(n)which can be written as:hBP(n)=2cos(ω0n)hLP(n)

Lowpass to Bandstop

We can transform a lowpass filter to a bandstop filter by combining the highpass and bandpass transformations. That is, first make the filter bandpass by shifting the lowpass response, and then invert in to get a bandstop response centered at ω0.

HBS(e) = 1 – (HLP(ej(ω–ω0)) + HLP(ej(ω+ω0)))

This yields the following coefficients:

for n=0hBS(n)=12cos(ω0n)hLP(n)for 1 |n|  NhBS(n)=2cos(ω0n)hLP(n)

Generalized Transformation

The transformations highlighted above can be combined to transform a lowpass filter to a lowpass, highpass, bandpass or bandstop filter with arbitrary cutoffs.

For example, to transform a lowpass filter with cutoff ωc1 to a highpass with cutoff ωc2, you first apply the lowpass-to-lowpass transformation to get a lowpass filter with cutoff ωc2, and then apply the lowpass-to-highpass transformation to get the highpass with cutoff ωc2.

To get a bandpass filter with center frequency ω0 and bandwidth β, we first apply the lowpass-to-lowpass transformation to go from a lowpass with cutoff ωc to a lowpass with cutoff β/2, and then apply the lowpass-to-bandpass transformation to get the desired bandpass filter. The same approach can be applied to a bandstop filter.

References

[1] P.Jarske, Y. Neuvo, and S. K. Mitra, "A simple approach to the design of linear phase FIR digital filters with variable characteristics", Signal Process. (Elsevier), vol. 14, pp. 313

Was this topic helpful?