Main Content

plotFilterErrors

Plot tracking filter errors

Since R2022b

Description

example

plotFilterErrors(tuner) plots the state estimate errors for a tracking filter tuned by the tuner.

  • If you tune the filter based on a truth timetable that contains the Position and Velocity columns, this function plots the position and velocity estimate errors on the x-, y-, and z-axes.

  • If you tune the filter based on a truth timetable that contains the State column, this function plots the estimate error for each state component.

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.2941          0.0000
   1       9.2749          0.1313
   2       9.1827          0.6852
   3       9.0777          1.1658
   4       9.0734          0.0937
   5       9.0548          0.2909
   6       9.0472          0.2754
   7       9.0477          0.0348
   8       9.0474          0.0501
   9       9.0474          0.0148
  10       9.0473          0.0141
  11       9.0473          0.0072
  12       9.0459          0.0621
  13       9.0455          0.0237
  14       9.0455          0.0054
  15       9.0455          0.0021
  16       9.0455          0.0019
  17       9.0452          0.0250
  18       9.0451          0.0177
  19       9.0451          0.0024
  20       9.0451          0.0005
  21       9.0451          0.0010
  22       9.0451          0.0007
  23       9.0451          0.0012
  24       9.0451          0.0007
  25       9.0451          0.0006
  26       9.0451          0.0003
  27       9.0451          0.0002
  28       9.0450          0.0153
  29       9.0450          0.0073
  30       9.0450          0.0013

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.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.

plotFilterErrors(tuner)

Input Arguments

collapse all

Tracking filter tuner, specified as a trackingFilterTuner object.

Version History

Introduced in R2022b