Filter Design Toolbox    
adaptkalman

Use a discrete-time Kalman filter in an adaptive filtering application

Syntax

Description

y = adaptkalman(x,d,s) applies a Kalman adaptive filter to the data vector x and the desired signal d. The filtered data is returned in y. To return the filter states after adaptation, specify the output argument s.

s is a structure containing the initialization settings that define the Kalman filter you are using and some output results, as shown in the table that follows. In the third column of the table, you see a list showing how the input arguments to initkalman correspond to elements in s.

Structure Element
Element Description
initkalman argument
s.coeffs
Kalman adaptive filter coefficients. Should be initialized with the initial values for the FIR filter coefficients. Updated coefficients are returned when you use s as an output argument. Contains filter order plus one elements in a vector.
w0
s.errcov
The state error covariance matrix. Initialize this element with the initial error state covariance matrix. An updated matrix is returned when you use s as an output argument. This is a square matrix of dimension filter order plus one. For example, for a 32nd-order filter, s.errcov is a 33-by-33 matrix.
k0
s.measvar
Contains the measurement noise variance matrix. Use the same value for all the elements in the matrix and adaptkalman returns a matrix of noise variance values -- a square matrix of dimension filter order plus one. For example, for a 32nd-order filter, s.measvar is a 33-by-33 matrix.
qm
s.procov
Contains the process noise covariance matrix. This is a square matrix of dimension filter order plus one. For example, for a 32nd-order filter, s.procov is a 33-by-33 matrix.
qp
s.states
Returns the states of the FIR filter when use s as an output argument. This is an optional input element. If omitted on input, it defaults to a zero vector of length equal to the filter order.
zi
s.gain
Kalman gain vector. Computed and returned after every iteration. This is a read-only value.

s.iter
Total number of iterations in adaptive filter run. This is a read-only value.

Use initkalman to configure the elements of input argument structure s.

[y,e] = adaptkalman(...) also returns the prediction error e.

[y,e,s] = adaptkalman(...) returns the updated structure s.

In applications where you need to know the intermediate filter states as the filter adapts to the unknown system, call adaptkalman inside a conditional program statement such as the following for-loop example.

In lieu of assigning the structure fields for s manually, use initkalman to populate structure s.

Examples

Use an adaptive Kalman filter to identify an unknown 32nd-order FIR filter (500 iterations). From Signal Processing Toolbox we use fir1 to create our unknown windowed lowpass FIR filter.

In the stem plot, you see that the original filter and the Kalman approximation/identification filter have identical response characteristics.

See Also

initkalman, adaptlms, adaptnlms, adaptrls, adaptsd, adaptse, adaptss

References

Haykin, S., Adaptive Filter Theory, Third Edition, Prentice-Hall, Inc., 1996.


  Functions--Alphabetical List adaptlms