Main Content

correct

Correct state and state estimation error covariance using tracking filter

Description

[xcorr,Pcorr] = correct(filter,zmeas) returns the corrected state, xcorr, and the corrected state estimation error covariance, Pcorr, for the next time step of the input tracking filter based on the current measurement, zmeas. The corrected values overwrite the internal state and state estimation error covariance of filter.

example

[xcorr,Pcorr] = correct(filter,zmeas,measparams) specifies additional parameters used by the measurement function that is defined in the MeasurementFcn property of filter. You can return any of the outputs from preceding syntaxes.

If filter is a trackingKF or trackingABF object, then you cannot use this syntax.

[xcorr,Pcorr] = correct(filter,zmeas,zcov) specifies additional measurement covariance, zcov, used in the MeasurementNoise property of filter.

You can use this syntax only when filter is a trackingKF object.

[xcorr,Pcorr,zcorr] = correct(filter,zmeas) also returns the correction of measurements, zcorr.

You can use this syntax only when filter is a trackingABF object.

[xcorr,Pcorr,zcorr] = correct(filter,zmeas,zcov) returns the correction of measurements, zcorr, and also specifies additional measurement covariance, zcov, used in the MeasurementNoise property of filter.

You can use this syntax only when filter is a trackingABF object.

correct(filter,___) updates filter with the corrected state and state estimation error covariance without returning the corrected values. Specify the tracking filter and any of the input argument combinations from preceding syntaxes.

xcorr = correct(filter,___) updates filter with the corrected state and state estimation error covariance but returns only the corrected state, xcorr.

Examples

collapse all

Create a two-dimensional trackingEKF object and use name-value pairs to define the StateTransitionJacobianFcn and MeasurementJacobianFcn properties. Use the predefined constant-velocity motion and measurement models and their Jacobians.

EKF = trackingEKF(@constvel,@cvmeas,[0;0;0;0], ...
    'StateTransitionJacobianFcn',@constveljac, ...
    'MeasurementJacobianFcn',@cvmeasjac);

Run the filter. Use the predict and correct functions to propagate the state. You may call predict and correct in any order and as many times you want. Specify the measurement in Cartesian coordinates.

measurement = [1;1;0];
[xpred, Ppred] = predict(EKF);
[xcorr, Pcorr] = correct(EKF,measurement);
[xpred, Ppred] = predict(EKF);
[xpred, Ppred] = predict(EKF)
xpred = 4×1

    1.2500
    0.2500
    1.2500
    0.2500

Ppred = 4×4

   11.7500    4.7500         0         0
    4.7500    3.7500         0         0
         0         0   11.7500    4.7500
         0         0    4.7500    3.7500

Input Arguments

collapse all

Filter for object tracking, specified as one of these objects:

Measurement of the tracked object, specified as a vector or matrix.

Data Types: single | double

Measurement function arguments, specified as a comma-separated list of arguments. These arguments are the same ones that are passed into the measurement function specified by the MeasurementFcn property of the tracking filter. If filter is a trackingKF or trackingABF object, then you cannot specify measparams.

Suppose you set MeasurementFcn to @cameas, and then call correct:

[xcorr,Pcorr] = correct(filter,frame,sensorpos,sensorvel)
The correct function internally calls the following:
meas = cameas(state,frame,sensorpos,sensorvel)

Measurement covariance, specified as an M-by-M matrix, where M is the dimension of the measurement. The same measurement covariance matrix is assumed for all measurements in zmeas.

Data Types: single | double

Output Arguments

collapse all

Corrected state of the filter, specified as a vector or matrix. The State property of the input filter is overwritten with this value.

Corrected state covariance of the filter, specified as a vector or matrix. The StateCovariance property of the input filter is overwritten with this value.

Corrected measurement of the filter, specified as a vector or matrix. You can return zcorr only when filter is a trackingABF object.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018b