Variable bandwidth FIR filter
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:
Define and set up your variable bandwidth FIR filter. See Construction.
step to filter
each channel of the input according to the properties of
The behavior of
step is specific to each object in
Starting in R2016b, instead of using the
vbw = dsp.VariableBandwidthFIRFilter returns
a System object,
vbw, which independently filters
each channel of the input over successive calls to the
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
vbw = dsp.VariableBandwidthFIRFilter(' returns a variable bandwidth FIR filter System object,
with each property set to the specified value. You can specify additional
name-value pair arguments in any order as (
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 non-tunable.
Specify the type of the filter as one of
FIR filter order
Specify the order of the FIR filter as a positive integer scalar. The default is 30. This property is non-tunable.
Specify the window function used to design the FIR filter as
Kaiser window parameter
Specify the Kaiser window parameter as a real scalar. This property
applies when you set the window property to
Filter cutoff frequency
Specify the filter cutoff frequency in Hz as a real, positive
scalar, smaller than the
Filter center frequency
Specify the filter center frequency in Hz as a real, positive
scalar, smaller than
Specify the filter bandwidth in Hertz as a real, positive scalar,
Chebyshev window sidelobe attenuation
Specify the Chebyshev window attenuation as a real, positive
scalar in decibels (dB). This property applies if you set the
|reset||Reset internal states of variable bandwidth FIR filter|
|step||Filter signal using variable bandwidth algorithm|
|Common to All System Objects|
Create System object with same property values
Expected number of inputs to a System object
Expected number of outputs of a System object
Check locked states of a System object (logical)
Allow System object property value changes
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent
step syntax. For example, myObject(x) becomes step(myObject,x).
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: vbw = dsp.VariableBandwidthFIRFilter('FilterType','Bandpass',... 'FilterOrder',100,... 'SampleRate',Fs,... 'CenterFrequency',1e4,... 'Bandwidth',4e3); tfe = dsp.TransferFunctionEstimator('FrequencyRange','onesided'); aplot = 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; sine = dsp.SineWave('SamplesPerFrame',FrameLength); for i=1:500 % Generate input x = sine() + randn(FrameLength,1); % Pass input through the filter y = vbw(x); % Transfer function estimation h = tfe(x,y); % Plot transfer function aplot(20*log10(abs(h))) % Tune bandwidth and center frequency of the FIR filter if (i==250) vbw.CenterFrequency = 5000; vbw.Bandwidth = 2000; end end
All transformations assume a lowpass filter of length 2N+1.
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:
where w(n) is the window vector. The lowpass filter coefficients are tuned to a new cutoff frequency ωc2 as follows:
There is no need to recompute the window every time you tune the cutoff frequency.
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(ejω) = 1 — HLP(ejω)
Taking the inverse discrete Fourier transform of the above response, we get the following highpass filter coefficients:
A bandpass filtered centered at frequency ω0 can be obtained by shifting the lowpass response:
HBP(ejω) = 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:
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(ejω) = 1 – (HLP(ej(ω–ω0)) + HLP(ej(ω+ω0)))
This yields the following coefficients:
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.
 Jarske, P.,Y. Neuvo, and S. K. Mitra, "A simple approach to the design of linear phase FIR digital filters with variable characteristics." Signal Processing. Vol. 14, Issue 4, June 1988, pp. 313-326.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).