Contenu principal

latcfilt

R2026b

Lattice and lattice-ladder filter implementation

Description

[f,g] = latcfilt(k,x) filters input signal x with the FIR lattice coefficients specified by k and returns the forward lattice filter result f and backward filter result g.

example

[f,g] = latcfilt(k,v,x) filters input signal x with the IIR lattice coefficients specified by k and ladder coefficients specified by v. Both k and v must be vectors, while x can be a matrix.

[f,g] = latcfilt(k,1,x) filters input signal x with the IIR lattice coefficients specified by k and returns the all-pole lattice filter result f and the allpass filter result g.

[f,g,zf] = latcfilt(___,"ic",zi,dim) specifies the initial lattice-state conditions zi and the dimension dim along which to process x for any of the previous syntaxes. Use zf to return the final lattice-state conditions.

Examples

collapse all

Generate a signal with 512 samples of white Gaussian noise.

x = randn(512,1);

Filter the data with an FIR lattice filter. Specify the reflection coefficients so that the lattice filter is equivalent to a 3rd-order moving average filter.

[f,g] = latcfilt([1/2 1],x);

Plot the maximum- and minimum-phase outputs of the lattice filter in separate plots

tiledlayout("flow")
nexttile
plot(f)
title('Maximum-Phase Output')
nexttile
plot(g)
title('Minimum-Phase Output')

Figure contains 2 axes objects. Axes object 1 with title Maximum-Phase Output contains an object of type line. Axes object 2 with title Minimum-Phase Output contains an object of type line.

Input Arguments

collapse all

Lattice coefficients, specified as a vector or matrix.

  • If you do not specify v, you can specify k as a matrix with the same number of columns as x. In this case, the function filters the ith column of x using a lattice filter whose coefficients come from the ith column of k.

  • If |k|≤1, then f corresponds to the minimum-phase output, and g corresponds to the maximum-phase output.

When filtering data, lattice coefficients can be used to represent

  • FIR filters

  • All-pole IIR filters

  • Allpass IIR filters

  • General IIR filters

Data Types: single | double
Complex Number Support: Yes

Input signal, specified as one of these:

  • Vector — Single-channel input signal.

  • Matrix — Multichannel input signal with as many channels as columns in x.

  • N-D array — Multidimensional array. In this case, also specify k as a vector and specify dim.

Data Types: single | double
Complex Number Support: Yes

Ladder coefficients, specified as a vector.

The length of v must be less than or equal to length(k)+1. If v has fewer than length(k)+1elements, then latcfilt pads v with zeros to until it reaches that length.

Data Types: single | double
Complex Number Support: Yes

Initial conditions of the lattice states, specified as one of these:

  • Scalar — The function sets the initial condition of each lattice state to zi.

  • Vector — zi must have the same length as k. This length represents the filter order or the number of lattice stages.

  • Matrix — Each column of zi must have the same length as k. The number of columns of zi must be equal to max(width(k),numel(x)/height(x)).

Data Types: single | double
Complex Number Support: Yes

Dimension along which to operate, specified as a positive integer scalar.

  • By default, the function operates along the first array dimension of x with size greater than 1.

  • To specify dim, the FIR lattice coefficients k must be a vector and you must specify all previous input arguments in order. To skip input arguments, use the empty vector [].

Data Types: double

Output Arguments

collapse all

Forward lattice filter, returned as a vector, matrix, or N-D array.

If k and x are vectors, f is a vector of the same size as x. Matrix arguments are permitted under these rules:

  • If x is a matrix and k is a vector, the function processes each column of x through the lattice filter specified by k.

  • If x is a vector and k is a matrix, the function uses each column of k to filter x and returns a matrix.

  • If x and k are both matrices with the same number of columns, then the function uses the ith column of k to filter the ith column of x and returns a matrix.

Backward lattice filter, returned as a vector, matrix, or N-D array of the same size as f.

Final conditions of the lattice states, returned as a vector or matrix. If zf is a vector, then it has the same length as k. If zf is a matrix, then each column has a length equal to the length of k. zf returns the final conditions in columns, regardless of the shape of x.

More About

collapse all

Algorithms

Assume a filter with reflection coefficients k = [k1 k2 ⋯ kn] and v = [v1 v2 ⋯ vn+1]. Depending on the filter impulse response, the latcfilt function uses the lattice or lattice-ladder structure to implement the filter. To learn more about these structures, see Lattice and Lattice-Ladder Filters.

The filter has n initial states, which are located at the inputs of each z-1 delay block in the filter implementation diagram.

  • When you specify zi as a scalar, latcfilt initializes the filter states by setting ζ1 = ζ2 = ⋯ =ζn = zi.

  • When you specify zi as a vector, latcfilt initializes the filter states by setting ζr = zi(r) for r = 1, 2, …, n.

  • When you specify zi as a matrix, then the state initialization repeats for each column of x.

For each sample of x across the first array dimension whose size is greater than 1 or across the dimension dim, the latcfilt function computes f and g from the lattice or lattice-ladder structure, updates the filter states, and repeats this operation until it finishes filtering the last sample of x.

The filter has n final states, which are located at the outputs of each z-1 delay block in the filter implementation diagram.

  • When you specify to return zf, latcfilt gathers the states computed during the filtering of the last sample of x, and stores these final states in zf as zf(r) = ζr, for r = 1, 2, …, n.

  • The filtering operation repeats for each column of x and latcfilt returns the final states in a new column of zf.

Extended Capabilities

expand all

Version History

Introduced before R2006a

expand all

See Also

| |