After you use the
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
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.
The output estimation error is the difference between the measured output,
y, and the estimated output,
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;
obj.State is the state value after you estimate the states using the
predict command. is the predicted state estimate for time
estimated using measured output until a previous time
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.
Low autocorrelation, except at zero time lag — To compute the
autocorrelation, you can use the MATLAB
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
correct command. The state estimation errors must satisfy the following
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
property of the filter. Similar values increase confidence in the performance of the