Main Content

statecovparts

Get and set part of state covariance matrix in insEKF

Since R2022a

Description

covparts = statecovparts(filter,stateName) returns the covariance submatrix corresponding to the specified state name of the filter. The returned submatrix is a square matrix extracted from along the main diagonal of the full state covariance matrix of the filter.

example

covparts = statecovparts(filter,sensor,stateName) returns the covariance submatrix corresponding to the specified state name of the sensor.

example

statecovparts(filter,stateName,value) sets the covariance submatrix corresponding to the specified state name of the filter to the specified value.

example

statecovparts(filter,sensor,stateName,value) sets the covariance submatrix corresponding to the specified state name of the specified sensor to the specified value.

example

Examples

collapse all

Create an insAccelerometer sensor object.

acc = insAccelerometer;

Construct an insEKF object using the two sensor objects.

filter = insEKF(acc);

View the state covariance matrix of the filter. By default, the state covariance matrix is a 10-by-10 identity matrix.

filter.StateCovariance
ans = 10×10

     1     0     0     0     0     0     0     0     0     0
     0     1     0     0     0     0     0     0     0     0
     0     0     1     0     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     0     1     0     0     0     0     0
     0     0     0     0     0     1     0     0     0     0
     0     0     0     0     0     0     1     0     0     0
     0     0     0     0     0     0     0     1     0     0
     0     0     0     0     0     0     0     0     1     0
     0     0     0     0     0     0     0     0     0     1

Set the diagonal of the covariance submatrix corresponding to the accelerometer to 3, and show the submatrix.

statecovparts(filter,acc,"Bias",3);  
statecovparts(filter,acc,"Bias")
ans = 3×3

     3     0     0
     0     3     0
     0     0     3

Set the diagonal of the covariance submatrix corresponding to the accelerometer to [1 2 3], and show the submatrix.

statecovparts(filter,acc,"Bias",[1 2 3]);  
statecovparts(filter,acc,"Bias")
ans = 3×3

     1     0     0
     0     2     0
     0     0     3

Set the covariance submatrix corresponding to the accelerometer to magic(3), and show the submatrix.

statecovparts(filter,acc,"Bias",magic(3));  
statecovparts(filter,acc,"Bias")
ans = 3×3

     8     1     6
     3     5     7
     4     9     2

Show the covariance submatrix corresponding to the accelerometer directly through the filter.

statecovparts(filter,"Accelerometer_Bias")
ans = 3×3

     8     1     6
     3     5     7
     4     9     2

View the altered state covariance matrix.

filter.StateCovariance
ans = 10×10

     1     0     0     0     0     0     0     0     0     0
     0     1     0     0     0     0     0     0     0     0
     0     0     1     0     0     0     0     0     0     0
     0     0     0     1     0     0     0     0     0     0
     0     0     0     0     1     0     0     0     0     0
     0     0     0     0     0     1     0     0     0     0
     0     0     0     0     0     0     1     0     0     0
     0     0     0     0     0     0     0     8     1     6
     0     0     0     0     0     0     0     3     5     7
     0     0     0     0     0     0     0     4     9     2

Input Arguments

collapse all

INS filter, specified as an insEKF object.

Name of a part of the state for the filter or the sensor, specified as a string scalar or character vector.

Use the stateinfo object function to find the names of state parts in the filter.

Example: "AngularVelocity"

Example: "Bias"

Data Types: char | string

Inertial sensor, specified as one of these objects used to construct the insEKF filter object:

Value for filter or sensor state part covariance matrix, specified as one of these options:

  • Real scalar — The diagonal elements of the resulting state part covariance matrix are all equal to the scalar.

  • N-element real-valued vector — The diagonal of the resulting state part covariance matrix is equal to the vector, where N is the dimension of the state corresponding to the stateName argument.

  • N-by-N real-valued matrix — The resulting state part covariance matrix is equal to the matrix, where N is the dimension of the state corresponding to the stateName argument.

Data Types: single | double

Output Arguments

collapse all

Covariance matrix corresponding to the state name, returned as an N-by-N real-valued matrix.

Extended Capabilities

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

Version History

Introduced in R2022a