Validate Online State Estimation at the Command Line
After you use the extendedKalmanFilter
, unscentedKalmanFilter
or particleFilter
commands for online state estimation of a nonlinear system,
validate the estimation before deploying the code in your application. If the validation
indicates low confidence in the estimation, then see Troubleshoot Online State Estimation for next steps. After
you have validated the online estimation results, you can generate C/C++ code or a
standalone application using MATLAB®
Coder™ or MATLAB
Compiler™ software.
To validate the performance of your filter, perform state estimation using measured or simulated output data from different scenarios.
Obtain output data from your system at different operating conditions and input values — To ensure that estimation works well under all operating conditions of interest. For example, suppose that you want to track the position and velocity of a vehicle using noisy position measurements. Measure the data at different vehicle speeds and slow and sharp maneuvers.
For each operating condition of interest, obtain multiple sets of experimental or simulated data with different noise realizations — To ensure different noise values do not deteriorate estimation performance.
For each of these scenarios, test the filter performance by examining the output estimation error and state estimation error. For an example about performing and validating online state estimation, see Nonlinear State Estimation Using Unscented Kalman Filter and Particle Filter.
Examine Output Estimation Error
The output estimation error is the difference between the measured output,
y
, and the estimated output, yEstimated
. You
can obtain the estimated output at each time step by using the measurement function of
the system. For example, if vdpMeasurementFcn.m
is the measurement
function for your nonlinear system, and you are performing state estimation using an
extended Kalman filter object, obj
, you can compute the estimated
output using the current state estimates as:
yEstimated = vdpMeasurementFcn(obj.State); estimationError = y-yEstimated;
Here obj.State
is the state value after you estimate the states using the predict
command. is the predicted state estimate for time k
,
estimated using measured output until a previous time k-1
.
If you are using extendedKalmanFilter
or
unscentedKalmanFilter
, you can also use residual
to get the estimation
error:
[residual,residualCovariance] = residual(obj,y);
The estimation errors (residuals) must have the following characteristics:
Small magnitude — Small errors relative to the size of the outputs increase confidence in the estimated values.
Zero mean
Low autocorrelation, except at zero time lag — To compute the autocorrelation, you can use the MATLAB
xcorr
command.
Examine State Estimation Error for Simulated Data
When you simulate the output data of your nonlinear system and use that data for state
estimation, you know the true state values. You can compute the errors between estimated
and true state values and analyze the errors. The estimated state value at any time step
is the value stored in obj.State
after you estimate the states using
the predict
or correct
command. The state estimation errors must satisfy the following
characteristics:
Small magnitude
Zero mean
Low autocorrelation, except at zero time lag
You can also compute the covariance of the state estimation error and compare it to
the state estimation error covariance stored in the StateCovariance
property of the filter. Similar values increase confidence in the performance of the
filter.
See Also
extendedKalmanFilter
| unscentedKalmanFilter
| particleFilter
| residual