Main Content


Plot tracking filter errors



plotFilterErrors(tuner) plots the position and velocity estimate errors on the x-, y-, and z-axes. The function also plots the 3-sigma covariance envelopes, which ideally contain roughly 99.7% of the state estimate errors for a consistent filter.


Use the tune object function before calling the plotFilterErrors function if you have changed any of these properties of the tuner:

  • FilterInitializationFcn

  • TunablePropertiesSource

  • CustomTunableProperties


collapse all

Load the tuning data containing the truth and detection data. The truth data has the position and velocity of one target for a duration of 9.5 seconds. The detection data has object detections of ten Monte-Carlo runs for the same period.


Create a trackingFilterTuner object.

tuner = trackingFilterTuner;

By default, the FiliterInitialization property of the tuner returns an initialization function that initializes a trackingEKF object.

initFcn = tuner.FilterInitializationFcn
initFcn = 

Initialize the trackingEKF object and display the untuned process noise.

filter = feval(tuner.FilterInitializationFcn,detlog{1});
     1     0     0
     0     1     0
     0     0     1

Specify the SolverOptions property so that the tuner displays the tuning progress for every iteration and set the maximum number of iterations to 30.

tuner.SolverOptions = optimoptions("fmincon",Display ="iter", ...

Using the tune object function, tune the filter with the detection log and the truth data. Return the tuned properties.

tunedProps = tune(tuner,detlog,truth);
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.

                                            First-order      Norm of
 Iter F-count            f(x)  Feasibility   optimality         step
    0       7    9.294119e+00    0.000e+00    3.977e-02
    1      14    9.274890e+00    0.000e+00    3.653e-02    1.313e-01
    2      21    9.182690e+00    0.000e+00    3.089e-02    6.852e-01
    3      28    9.077721e+00    0.000e+00    4.671e-02    1.166e+00
    4      35    9.073360e+00    0.000e+00    4.441e-02    9.369e-02
    5      42    9.054802e+00    0.000e+00    4.320e-02    2.909e-01
    6      49    9.047225e+00    0.000e+00    2.914e-02    2.754e-01
    7      56    9.047721e+00    0.000e+00    1.084e-02    3.484e-02
    8      63    9.047374e+00    0.000e+00    4.113e-03    5.013e-02
    9      70    9.047364e+00    0.000e+00    2.893e-03    1.480e-02
   10      77    9.047318e+00    0.000e+00    1.734e-03    1.414e-02
   11      84    9.047302e+00    0.000e+00    9.999e-04    7.210e-03
   12      91    9.045889e+00    0.000e+00    1.152e-03    6.212e-02
   13      98    9.045539e+00    0.000e+00    8.820e-04    2.369e-02
   14     105    9.045480e+00    0.000e+00    8.302e-04    5.352e-03
   15     112    9.045468e+00    0.000e+00    6.217e-04    2.099e-03
   16     119    9.045470e+00    0.000e+00    2.000e-04    1.936e-03
   17     126    9.045223e+00    0.000e+00    1.153e-03    2.499e-02
   18     133    9.045106e+00    0.000e+00    3.033e-04    1.772e-02
   19     140    9.045095e+00    0.000e+00    1.018e-04    2.418e-03
   20     147    9.045095e+00    0.000e+00    1.007e-04    5.276e-04
   21     154    9.045095e+00    0.000e+00    9.443e-05    9.549e-04
   22     161    9.045095e+00    0.000e+00    8.803e-05    7.331e-04
   23     168    9.045095e+00    0.000e+00    7.113e-05    1.197e-03
   24     175    9.045094e+00    0.000e+00    1.094e-04    7.076e-04
   25     182    9.045094e+00    0.000e+00    1.111e-04    6.153e-04
   26     189    9.045094e+00    0.000e+00    7.520e-05    2.503e-04
   27     196    9.045094e+00    0.000e+00    4.000e-05    1.866e-04
   28     203    9.045034e+00    0.000e+00    3.476e-04    1.553e-02
   29     210    9.045015e+00    0.000e+00    3.322e-05    7.214e-03
   30     217    9.045013e+00    0.000e+00    1.526e-05    1.220e-03

Solver stopped prematurely.

fmincon stopped because it exceeded the iteration limit,
options.MaxIterations = 3.000000e+01.

Set the filter tunable properties by using the setTunedProperty object function of the filter. Display the tuned process noise.

    0.0000    0.0001    0.0000
    0.0001    0.0149    0.0007
    0.0000    0.0007    0.0002

Plot the filter estimation error after tuning by using the plotFilterErrors object function.


Figure Filter estimate error contains 6 axes objects. Axes object 1 contains 30 objects of type line. Axes object 2 contains 30 objects of type line. Axes object 3 contains 30 objects of type line. Axes object 4 contains 30 objects of type line. Axes object 5 contains 30 objects of type line. Axes object 6 contains 30 objects of type line.

Input Arguments

collapse all

Tracking filter tuner, specified as a trackingFilterTuner object.

Version History

Introduced in R2022b