# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# dsp.AllpassFilter System object

Package: dsp

Single section or cascaded allpass filter

 Note:   MATLAB® code with `LatticeCoefficients`, `AllpassCoefficients`, and `WDFCoefficients` properties set to cell arrays will error in a future release. Set these properties to array values instead.

## Description

The `AllpassFilter` object filters each channel of the input using Allpass filter implementations. This System object™ supports code generation. To import this object into Simulink®, use the MATLAB System block.

To filter each channel of the input:

1. Define and set up your Allpass filter. See Construction.

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

 Note:   Starting in R2016b, instead of using the `step` method to perform the operation defined by the System object, you can call the object with arguments, as if it were a function. For example, ```y = step(obj,x)``` and `y = obj(x)` perform equivalent operations.

## Construction

`Allpass = dsp.AllpassFilter` returns an Allpass filter System object, `Allpass`, that filters each channel of the input signal independently using an allpass filter, with the default structure and coefficients.

```Allpass = dsp.AllpassFilter('PropertyName',PropertyValue, ...)``` returns an Allpass filter System object, `Allpass`, with each property set to the specified value.

## Properties

 `Structure` Internal allpass filter structure You can specify the internal allpass filter implementation structure as one of | `Minimum multiplier` | `Lattice` | `Wave Digital Filter`. The default is `Minimum multiplier`. Each structure uses a different set of coefficients, independently stored in the corresponding object property. `AllpassCoefficients` Allpass polynomial coefficients Specify the real allpass polynomial filter coefficients. This property is applicable only when the `Structure` property is set to `Minimum multiplier`. Specify this property as either an N-by-`1` or N-by-`2` matrix of N first-order or second-order allpass sections. The default value of this property is `[-2^(-1/2) 0.5]`. The default value defines a stable second-order allpass filter with poles and zeros located at ±π/3 in the Z plane. This property is tunable. `WDFCoefficients` Wave Digital Filter allpass coefficients Specify the real allpass coefficients in the Wave Digital Filter form. This property is only applicable when the `Structure` property is set to `Wave Digital Filter`. Specify this property as either a N-by-`1` or N-by-`2` matrix of N first-order or second-order allpass sections. All elements must have absolute values less than or equal to `1`. The default value for this property is [`1/2, -2^(1/2)/3`]. This value is a transformed version of the default value of `AllpassCoefficients`, computed using `allpass2wdf(AllpassCoefficients)`. These coefficients define the same stable second-order allpass filter as when `Structure` is set to `'Minimum multiplier'`. This property is tunable. `LatticeCoefficients` Lattice allpass coefficients Specify the real or complex allpass coefficients as lattice reflection coefficients. This property is applicable only if the `Structure` property is set to `Lattice`. Specify this property as either a row vector (single-section configuration) or a column vector. The default is` [-2^(1/2)/3, 1/2]`. This value is a transformed and transposed version of the default value of `AllpassCoefficients`, computed using `transpose(tf2latc([1 h.AllpassCoefficients]))`. These coefficients define the same stable second-order allpass filter as when `Structure` is set to `'Lattice'`. This property is tunable. `TrailingFirstOrderSection` Indicate if last section is first order Indicate if last section is first order or second order. When you set `TrailingFirstOrderSection` to `true`, the last section is considered to be first-order, and the second element of the last row of the N-by-2 matrix is ignored. When you set `TrailingFirstOrderSection` to `false`, the last section is considered to be second-order. The default is `false`.

## Methods

 clone Create System object with same property values isLocked Locked status for input attributes and nontunable properties release Allow property value and input characteristics changes reset Reset internal states of a System object step Process inputs using allpass filter

For additional methods, see Analysis Methods for Filter System Objects.

For a complete list of analysis methods supported for the `dsp.AllpassFilter` object, enter `dsp.AllpassFilter.helpFilterAnalysis` at the MATLAB command prompt.

## Examples

expand all

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).

Construct the Allpass Filters

```Fs = 48000; % in Hz FL = 1024; APF1 = dsp.AllpassFilter('AllpassCoefficients',... [-0.710525516540603 0.208818210000029]); APF2 = dsp.AllpassFilter('AllpassCoefficients',... [-0.940456403667957 0.6;... -0.324919696232907 0],... 'TrailingFirstOrderSection',true); ```

Construct the Transfer Function Estimator to estimate the transfer function between the random input and the Allpass filtered output

```TFE = dsp.TransferFunctionEstimator('FrequencyRange',... 'onesided','SpectralAverages',2); ```

Construct the ArrayPlot to plot the magnitude response

```AP = dsp.ArrayPlot('PlotType','Line','YLimits', [-80 5],... 'YLabel','Magnitude (dB)','SampleIncrement', Fs/FL,... 'XLabel','Frequency (Hz)','Title','Magnitude Response',... 'ShowLegend', true,'ChannelNames',{'Magnitude Response'}); ```

Filter the Input and show the magnitude response of the estimated transfer function between the input and the filtered output

```tic; while toc < 5 in = randn(FL,1); out = 0.5.*(APF1(in) + APF2(in)); A = TFE(in, out); AP(db(A)); end ```

## Algorithms

The transfer function of an allpass filter is given by

$H\left(z\right)=\frac{c\left(n\right)+c\left(n-1\right){z}^{-1}+...+{z}^{-n}}{1+c\left(1\right){z}^{-1}+...+c\left(n\right){z}^{-n}}$.

c is allpass polynomial coefficients vector. The order, n, of the transfer function is the length of vector c.

In the minimum multiplier form and wave digital form, the allpass filter is implemented as a cascade of either second-order (biquad) sections or first-order sections. When the coefficients are specified as an N-by-2 matrix, each row of the matrix specifies the coefficients of a second-order filter. The last element of the last row can be ignored based on the trailing first-order setting. When the coefficients are specified as an N-by-1 matrix, each element in the matrix specifies the coefficient of a first-order filter. The cascade of all the filter sections forms the allpass filter.

In the lattice form, the coefficients are specified as a vector.

These structures are computationally more economical and structurally more stable compared to the generic IIR filters, such as df1, df1t, df2, df2t. For all structures, the allpass filter can be a single-section or a multiple-section (cascaded) filter. The different sections can have different orders, but they are all implemented according to the same structure.

### Minimum Multiplier

This structure realizes the allpass filter with the minimum number of required multipliers, equal to the order `n`. It also uses `2n` delay units and `2n` adders. The multipliers uses the specified coefficients, which are equal to the polynomial vector c in the allpass transfer function. In this second-order section of the minimum multiplier structure, the coefficients vector, c, is equal to [```0.1 -0.7```].

### Wave Digital Filter

This structure uses `n` multipliers, but only `n` delay units, at the expense of requiring `3n` adders. To use this structure, specify the coefficients in wave digital filter (WDF) form. Obtain the WDF equivalent of the conventional allpass coefficients using `allpass2wdf(allpass_coefficients)`. To convert WDF coefficients into the equivalent allpass polynomial form, use `wdf2allpass(WDF coefficients)`. In this second-order section of the WDF structure, the coefficients vector w is equal to `allpass2wdf([0.1 -0.7])`.

### Lattice

This lattice structure uses `2n` multipliers, `n` delay units, and `2n` adders. To use this structure, specify the coefficients as a vector.

You can obtain the lattice equivalent of the conventional allpass coefficients using `transpose(tf2latc(1, [1 allpass_coefficients]))`. In the following second-order section of the lattice structure, the coefficients vector is computed using ```transpose(tf2latc(1, [1 0.1 -0.7]))```. Use these coefficients for a filter that is functionally equivalent to the minimum multiplier structure with coefficients [0.1 -0.7].

## References

[1] Regalia, Philip A. and Mitra Sanjit K. and Vaidyanathan, P. P. (1988) "The Digital All-Pass Filter: AVersatile Signal Processing Building Block." Proceedings of the IEEE, Vol. 76, No. 1, 1988, pp. 19–37

[2] M. Lutovac, D. Tosic, B. Evans, Filter Design for Signal Processing Using MATLAB and Mathematica. Prentice Hall, 2001