| Filter Design Toolbox | ![]() |
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.
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.
for n = 1:length(x) [y(n),e(n),s] = adaptkalman(x(n),d(n),s); % States (The fields of s) here may be modified here. end
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.
x = 0.1*randn(1,500); % Input to the filter b = fir1(31,0.5); % FIR system to be identified d = filter(b,1,x); % Desired signal w0 = zeros(1,32); % Intial filter coefficients k0 = 0.5*eye(32); % Initial state error correlation matrix qm = 2; % Measurement noise covariance qp = 0.1*eye(32); % Process noise covariance s = initkalman(w0,k0,qm,qp); [y,e,s] = adaptkalman(x,d,s); stem([b.',s.coeffs.']); legend('Actual','Estimated'); title('System Identification of an FIR filter via Kalman Filter'); grid on;
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 | ![]() |