Main Content

plotFilterErrors

Plot tracking filter errors

Since R2022b

Description

example

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.

Note

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

  • FilterInitializationFcn

  • TunablePropertiesSource

  • CustomTunableProperties

Examples

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.

load("filterTuningData.mat","truth","detlog");

Create a trackingFilterTuner object and set the Solver property to "fmincon".

tuner = trackingFilterTuner(Solver="fmincon");

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

initFcn = tuner.FilterInitializationFcn
initFcn = 
"initcvekf"

Initialize the trackingEKF object and display the untuned process noise.

filter = feval(tuner.FilterInitializationFcn,detlog{1});
disp(filter.ProcessNoise);
     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",MaxIterations=30);

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);
Iter        RMSE          Step Size
   0       9.2946          0.0000
   1       9.2751          0.1324
   2       9.1820          0.6904
   3       9.0754          1.2832
   4       9.0747          0.1351
   5       9.0528          0.3302
   6       9.0507          0.1613
   7       9.0479          0.0803
   8       9.0474          0.0552
   9       9.0476          0.0463
  10       9.0477          0.0085
  11       9.0476          0.0194
  12       9.0476          0.0064
  13       9.0461          0.0603
  14       9.0456          0.0280
  15       9.0455          0.0040
  16       9.0455          0.0013
  17       9.0455          0.0015
  18       9.0452          0.0254
  19       9.0451          0.0141
  20       9.0451          0.0022
  21       9.0451          0.0010
  22       9.0451          0.0026
  23       9.0451          0.0037
  24       9.0451          0.0027
  25       9.0451          0.0015
  26       9.0451          0.0009
  27       9.0451          0.0005
  28       9.0451          0.0003
  29       9.0451          0.0002
  30       9.0451          0.0001

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.

setTunedProperties(filter,tunedProps);
disp(filter.ProcessNoise);
    0.0004    0.0008    0.0002
    0.0008    0.0152    0.0007
    0.0002    0.0007    0.0004

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

plotFilterErrors(tuner)

Figure Filter estimate error contains 6 axes objects. Axes object 1 with xlabel Time [sec], ylabel X_{Error} contains 20 objects of type line, patch. Axes object 2 with xlabel Time [sec], ylabel V_X_{Error} contains 20 objects of type line, patch. Axes object 3 with xlabel Time [sec], ylabel Y_{Error} contains 20 objects of type line, patch. Axes object 4 with xlabel Time [sec], ylabel V_Y_{Error} contains 20 objects of type line, patch. Axes object 5 with xlabel Time [sec], ylabel Z_{Error} contains 20 objects of type line, patch. Axes object 6 with xlabel Time [sec], ylabel V_Z_{Error} contains 20 objects of type line, patch. These objects represent Realizations, 3\sigma.

Input Arguments

collapse all

Tracking filter tuner, specified as a trackingFilterTuner object.

Version History

Introduced in R2022b