www.gusucode.com > control 案例程序 matlab源码代码 > control/SpecifyProcessAndMeasurementNoiseCovariancesInEKFObjectExample.m

    %% Specify Process and Measurement Noise Covariances in Extended Kalman Filter Object
%%
% Create an extended Kalman filter object for a van der Pol oscillator with
% two states and one output. Use the previously written and saved state
% transition and measurement functions, |vdpStateFcn.m| and 
% |vdpMeasurementFcn.m|. These 
% functions are written for additive process and measurement noise terms.
% Specify the initial state values for the two states as [2;0].
%
% Since the system has two states and the process noise is additive, 
% the process noise is a 2-element vector and the process noise covariance 
% is a 2-by-2 matrix. Assume there is no cross-correlation between process 
% noise terms, and both the terms have the same variance 0.01. You can 
% specify the process noise covariance as a scalar. The software uses the 
% scalar value to create a 2-by-2 diagonal matrix with 0.01 on the diagonals.
%
% Specify the process noise covariance during object construction.
obj = extendedKalmanFilter(@vdpStateFcn,@vdpMeasurementFcn,[2;0],...
    'ProcessNoise',0.01);
%%
% Alternatively, you can specify noise covariances after object
% construction using dot notation. For example, specify the measurement 
% noise covariance as 0.2.
obj.MeasurementNoise = 0.2;
%%
% Since the system has only one output, 
% the measurement noise is a 1-element vector and the |MeasurementNoise| 
% property denotes the variance of the measurement noise.