Main Content

dsp.IIRHalfbandDecimator

Decimate by factor of two using polyphase IIR

Description

Thedsp.IIRHalfbandDecimatorSystem object™ performs efficient polyphase decimation of the input signal by a factor of two. To design the halfband filter, you can specify the object to use an elliptic design or a quasi-linear phase design. The object uses these design methods to compute the filter coefficients. To filter the inputs, the object uses a polyphase structure. The allpass filters in the polyphase structure are in a minimum multiplier form.

Elliptic design introduces nonlinear phase and creates the filter using fewer coefficients than quasi linear design. Quasi-linear phase design overcomes phase nonlinearity at the cost of additional coefficients.

Alternatively, instead of designing the halfband filter using a design method, you can specify the filter coefficients directly. When you choose this option, the allpass filters in the two branches of the polyphase implementation can be in a minimum multiplier form or in a wave digital form.

You can also use thedsp.IIRHalfbandDecimatorobject to implement the analysis portion of a two-band filter bank to filter a signal into lowpass and highpass subbands.

To filter and downsample your data:

  1. Create thedsp.IIRHalfbandDecimatorobject and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, seeWhat Are System Objects?

Creation

Description

iirhalfbanddecim= dsp.IIRHalfbandDecimatorreturns a halfband decimator,iirhalfbanddecim, with the default settings. Under the default settings, the System object filters and downsamples the input data with a halfband frequency of22050Hz, a transition width of4100Hz, and a stopband attenuation of80dB.

example

iirhalfbanddecim= dsp.IIRHalfbandDecimator(Name,Value)returns an IIR halfband decimator, with additional properties specified by one or moreName,Valuepair arguments.

Example:iirhalfbanddecim = dsp.IIRHalfbandDecimator('Specification','Filter order and stopband attenuation')creates an IIR halfband decimator object with filter order set to9and stopband attenuation set to80dB.

Properties

expand all

Unless otherwise indicated, properties arenontunable,这意味着你无法改变他们的价值观calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

If a property istunable, you can change its value at any time.

For more information on changing property values, seeSystem Design in MATLAB Using System Objects.

Filter design parameters, specified as a character vector. When you setSpecificationto one of the filter design options, you can specify the filter design parameters using the correspondingFilterOrder,StopbandAttenuation, andTransitionWidthproperties. Also, you can specify the design method usingDesignMethod. When you setSpecificationto'Coefficients', you can specify the coefficients directly.

Order of the IIR halfband filter, specified as a positive scalar integer. If you setDesignMethodto'Elliptic', thenFilterOrdermust be an odd integer greater than one. If you setDesignMethodto'Quasi-linear phase', thenFilterOrdermust be a multiple of four.

Dependencies

This property applies when you setSpecificationto'Filter order and stopband attenuation'or'Filter order and transition width'.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Minimum attenuation needed in the stopband of the IIR halfband filter, specified as a positive real scalar. Units are in dB.

Dependencies

This property applies only when you setSpecificationto'Filter order and stopband attenuation'or'Transition width and stopband attenuation'.

Data Types:single|double

Transition width of the IIR halfband filter, specified as a positive real scalar. Units are in Hz. The value of the transition width must be less than half the input sample rate.

Dependencies

This property applies only when you setSpecificationto'Transition width and stopband attenuation'or'Filter order and transition width'.

Data Types:single|double

Design method for the IIR halfband filter, specified as'Elliptic'or'Quasi-linear phase'. When the property is set to'Quasi-linear phase', the first branch of the polyphase structure is a pure delay, which results in an approximately linear phase response.

Dependencies

This property applies only when you setSpecificationto any accepted value except'Coefficients'.

Input sample rate, specified as a positive real scalar. Units are in Hz.

Dependencies

This property applies only when you setSpecificationto any accepted value except'Coefficients'.

Data Types:single|double

Internal allpass filter implementation structure, specified as'Minimum multiplier'or'Wave Digital Filter'.

这个属性不是可调。

Dependencies

This property applies only when you set'Specification'to'Coefficients'. Each structure uses a different coefficients set, independently stored in the corresponding object property.

Allpass polynomial filter coefficients of the first branch, specified as anN-by-1orN-by-2matrix.Nis the number of first-order or second-order allpass sections.

Tunable:Yes

Dependencies

This property applies only when you setSpecificationto'Coefficients'andStructureto'Minimum multiplier'.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Allpass polynomial filter coefficients of the second branch, specified as anN-by-1orN-by-2matrix.Nis the number of first-order or second-order allpass sections.

Tunable:Yes

Dependencies

This property applies only when you setSpecificationto'Coefficients'andStructureto'Minimum multiplier'.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Allpass filter coefficients of the first branch in Wave Digital Filter form, specified as anN-by-1orN-by-2matrix.Nis the number of first-order or second-order allpass sections. Each element must have an absolute value less than or equal to1.

这个属性不是可调。

Dependencies

This property applies only when you setSpecificationto'Coefficients'andStructureto'Wave Digital Filter'.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Allpass filter coefficients of the second branch in Wave Digital Filter form, specified as the comma-separated pair consisting of'WDFCoefficients2'and aN-by-1orN-by-2matrix.Nis the number of first-order or second-order allpass sections. Each element must have an absolute value less than or equal to 1.

这个属性不是可调。

Dependencies

This property applies only when you set'Specification'to'Coefficients'and'Structure'to'Wave Digital Filter'.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Flag to make the first allpass branch a delay, specified as a logical scalar. When this property is true, the first branch is treated as a pure delay and the propertiesAllpassCoefficients1andWDFCoefficients1do not apply.

这个属性不是可调。

Dependencies

This property applies only when you setSpecificationto'Coefficients'.

Length of the first branch delay, specified as a finite positive scalar. The value of this property specifies the number of samples by which you can delay the input to the first branch.

这个属性不是可调。

Dependencies

This property applies only when you setSpecificationto'Coefficients'andHasPureDelayBranchto 1.

Data Types:single|double

Option to treat the last section of the second branch as first order, specified as a logical scalar. When this property is 1 and the coefficients of the second branch are in anN-by-2 matrix, the object ignores the second element of the last row of the matrix. The last section of the second branch then becomes a first-order section. When this property is set to0, the last section of the second branch is a second-order section. When the coefficients of the second branch are in anN-by-1 matrix, this property is ignored.

这个属性不是可调。

Dependencies

This property applies only when you setSpecificationto'Coefficients'.

Usage

Description

example

ylow= iirhalfbanddecim(x)filters the input signal,x, using the IIR halfband filter,iirhalfbanddecim, and downsamples the output by a factor of 2.

example

[ylow,yhigh] = iirhalfbanddecim(x)computes theylowandyhigh, of the analysis filter bank,iirhalfbanddecimfor inputx. AKi-by-Ninput matrix is treated asNindependent channels. The System object generates two power-complementary output signals by adding and subtracting the two polyphase branch outputs respectively.ylowandyhighare of the same size (Ko-by-N) and data type.Ko=Ki/2, where2is the decimation factor.

Input Arguments

expand all

Data input, specified as a column vector or a matrix. The number of rows in the input signal must be even since the decimation factor is always 2 for this object. If the input is a matrix, each column is treated as an independent channel.

Data Types:single|double
Complex Number Support:Yes

Output Arguments

expand all

Lowpass subband of decimator output, returned as a column vector or a matrix. The output,ylowis a lowpass halfband filtered and downsampled version of the inputx. Due to the halfband nature of the filter, the downsampling factor is always 2.

Data Types:single|double
Complex Number Support:Yes

Highpass subband of decimator output, returned as a column vector or a matrix. The output,yhighis a highpass halfband filtered and downsampled version of the inputx. Due to the halfband nature of the filter, the downsampling factor is always 2.

Data Types:single|double
Complex Number Support:Yes

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object namedobj, use this syntax:

release(obj)

expand all

freqz Frequency response of discrete-time filterSystem object
fvtool Visualize frequency response of DSP filters
info Information about filterSystem object
cost Estimate cost of implementing filterSystem object
polyphase Polyphase decomposition of multirate filter
step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

collapse all

Create a minimum-order lowpass IIR halfband decimation filter for data sampled at 44.1 kHz. The filter has a transition width of 4.1 kHz, and a stopband attenuation of 80 dB.

IIRHalfbandDecim = dsp.IIRHalfbandDecimator(...'DesignMethod','Quasi-linear phase');

Obtain the filter coefficients.

c = coeffs(IIRHalfbandDecim);

Plot the magnitude and phase response.

fvtool(IIRHalfbandDecim,'Analysis','freq')

Figure Magnitude Response (dB) and Phase Response contains an axes object. The axes object with title Magnitude Response (dB) and Phase Response contains an object of type line.

Use a halfband analysis filter bank and interpolation filter to extract the low frequency subband from a speech signal.

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalentstep语法。For example,obj(x)becomesstep(obj,x).

Note:TheaudioDeviceWriterSystem object™ is not supported inMATLAB Online.

Set up the audio file reader, the analysis filter bank, the audio device writer, and the interpolation filter. The sampling rate of the audio data is 22050 Hz. The halfband filter has an order of 21 and a transition width of 2 kHz.

afr = dsp.AudioFileReader('speech_dft.mp3','SamplesPerFrame',1024); filterspec ='Filter order and transition width'; Order = 21; TW = 2000; IIRHalfbandDecim = dsp.IIRHalfbandDecimator(...'Specification',filterspec,'FilterOrder',Order,...'TransitionWidth',TW,'SampleRate',afr.SampleRate); IIRHalfbandInterp = dsp.IIRHalfbandInterpolator(...'Specification',filterspec,'FilterOrder',Order,...'TransitionWidth',TW,'SampleRate',afr.SampleRate/2); ap = audioDeviceWriter('SampleRate',afr.SampleRate);

View the magnitude response of the halfband filter.

fvtool(IIRHalfbandDecim)

Figure Magnitude Response (dB) contains an axes object. The axes object with title Magnitude Response (dB) contains 2 objects of type line.

Read the speech signal from the audio file in frames of 1024 samples. Filter the speech signal into lowpass and highpass subbands with a halfband frequency of 5512.5 Hz. Reconstruct a lowpass approximation of the speech signal by interpolating the lowpass subband. Play the filtered output.

while~isDone(afr) audioframe = afr(); xlo = IIRHalfbandDecim(audioframe); ylow = IIRHalfbandInterp(xlo); ap(ylow);end

Wait until the audio file ends, and then close the input file and release the audio output resource.

release(afr); release(ap);

Use a halfband decimator and interpolator to implement a two-channel filter bank. This example uses an audio file input and shows that the power spectrum of the filter bank output does not differ significantly from the input.

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example,obj(x)becomesstep(obj,x).

Note: TheaudioDeviceWriterSystem object™ is not supported in MATLAB Online.

Set up the audio file reader and audio device writer. Construct the IIR halfband decimator and interpolator. Finally, set up the spectrum analyzer to display the power spectra of the filter-bank input and output.

AF = dsp.AudioFileReader('speech_dft.mp3','SamplesPerFrame',1024); AP = audioDeviceWriter('SampleRate',AF.SampleRate); filterspec ='Filter order and transition width'; Order = 51; TW = 2000; IIRHalfbandDecim = dsp.IIRHalfbandDecimator(...'Specification',filterspec,'FilterOrder',Order,...'TransitionWidth',TW,'SampleRate',AF.SampleRate); IIRHalfbandInterp = dsp.IIRHalfbandInterpolator(...'Specification',filterspec,'FilterOrder',Order,...'TransitionWidth',TW,'SampleRate',AF.SampleRate/2,...'FilterBankInputPort',true); SpecAna = spectrumAnalyzer('SampleRate',AF.SampleRate,...'PlotAsTwoSidedSpectrum',false,...'ShowLegend',true,...'ChannelNames',{'Input signal','Filtered output signal'});

Read the audio 1024 samples at a time. Filter the input to obtain the lowpass and highpass subband signals decimated by a factor of two. This is the analysis filter bank. Use the halfband interpolator as the synthesis filter bank. Display the running power spectrum of the audio input and the output of the synthesis filter bank. Play the output.

while~isDone(AF) audioInput = AF(); [xlo,xhigh] = IIRHalfbandDecim(audioInput); audioOutput = IIRHalfbandInterp(xlo,xhigh); spectrumInput = [audioInput audioOutput]; SpecAna(spectrumInput); AP(audioOutput);endrelease(AF); release(AP); release(SpecAna);

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstep语法。例如,myObject (myOb (x)变成了一步ject,x).

Create a halfband decimator for data sampled at 44.1 kHz. Use a minimum-order design with a transition width of 2 kHz and a stopband attenuation of 60 dB.

IIRHalfbanddecim = dsp.IIRHalfbandDecimator(...'Specification','Transition width and stopband attenuation',...'TransitionWidth',2000,'StopbandAttenuation',60,'SampleRate',44.1e3);

Filter a two-channel input into lowpass and highpass subbands.

x = randn(1024,2); [ylow,yhigh] = IIRHalfbanddecim(x);

Algorithms

expand all

References

[1] Lang, M.Allpass Filter Design and Applications.IEEE Transactions on Signal Processing. Vol. 46, No. 9, Sept 1998, pp. 2505–2514.

[2] Harris, F.J.Multirate Signal Processing for Communication Systems. Prentice Hall. 2004, pp. 208–209.

[3] Regalia, Phillip A., Sanjit K. Mitra, and P. P. Vaidyanathan. "The Digital All-Pass Filter: A Versatile Signal Processing Building Block."Proceedings of the IEEE.Vol. 76, Number 1, 1988, pp. 19-37.

Extended Capabilities

Version History

Introduced in R2015b