This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

switchimm

Model conversion function for trackingIMM object

Syntax

x = switchimm(modelType1,x1,modelType2)
x = switchimm(___,x2)

Description

example

x = switchimm(modelType1,x1,modelType2) converts the State or StateCovariance properties of the trackingIMM object from modelType1 state definition to modelType2 state definition.

  • modelType1 –– Specifies the string name of the current motion model.

  • x1 –– Specifies State or StateCovariance corresponding to modelType1.

  • modelType2 –– Specifies the string name of the motion model to which x1 needs to be converted.

example

x = switchimm(___,x2) additionally lets you specify the size and type of the output. When not specified, x has the same data type and dimensionality as x1.

x2 specifies State or StateCovariance corresponding to modelType2.

Examples

collapse all

Convert state from constant acceleration model to constant velocity model using the switchimm function.

Initialization

Set the current model to 'constacc' and the destination model to 'constvel'. The variable x1 defines the state in the current model.

modelType1 = 'constacc';
modelType2 = 'constvel';
x1 = single([1;2;3;4;5;6]);

Conversion

The switchimm function converts the 2-D constant acceleration state input to a 2-D constant velocity state output. The output has the same dimensionality and data type as the input x1.

x = switchimm(modelType1,x1,modelType2)
x = 4x1 single column vector

     1
     2
     4
     5

Convert state from constant acceleration model to constant turn model using the switchimm function. Specify x2 as an input parameter.

Initialization

Set the current model to 'constacc' and the destination model to 'constturn'. The variable x1 defines the state in the current model. The size and data type of the output is determined by the optional input x2.

modelType1 = 'constacc';
modelType2 = 'constturn';
x1 = [1;2;3;4;5;6];
x2 = [0;0;0;0;0;0;0];

Conversion

The switchimm function converts the 2-D constant acceleration state input to a 3-D constant turn model state output. The output has the same size and data type as the input x2.

x = switchimm(modelType1,x1,modelType2,x2)
x = 7×1

     1
     2
     4
     5
     0
     0
     0

Input Arguments

collapse all

Current motion model, specified as:

  • 'constvel' –– Constant velocity motion model.

  • 'constacc' –– Constant-acceleration motion model.

  • 'constturn' –– Constant turn-rate motion model.

State vector or state covariance matrix corresponding to the current model in modelType1, specified as an L-by-1 real vector or an L-by-L real matrix.

The size of the state vector must fit the motion model. For example, if the modelType is 'constvel', the state vector must be of size 2, 4, or 6. Similarly, if the modelType is 'constacc', the state vector must be of size 3, 6, or 9. If the modelType is 'constturn', the state vector must be of size 5, 7, 10, 15, 14, or 21. The relationship between model type, state size, and the space dimension is given by the following table:

modelType1Supported Space DimensionState size
'constvel'1-D, 2-D, 3-D

2 ✕ Space dimension

'constacc'1-D, 2-D, 3-D

3 ✕ Space dimension

'constturn'2-D and 3-D

5 for 2-D space and 7 for 3-D space

The 'constturn' model type supports only 2-D and 3-D spaces, since a turn cannot be made in 1-D space. If the space dimension is computed to be 1-D, that is, the state size equals 5 or 7, the function treats the output dimension as 2 and the values corresponding to the second dimension are set to 0. For example, run the following in the MATLAB® command prompt:

switchimm('constvel',rand(2,1),'constturn')

Data Types: single | double

Motion model to which x1 needs to be converted, specified as:

  • 'constvel' –– Constant velocity motion model.

  • 'constacc' –– Constant-acceleration motion model.

  • 'constturn' –– Constant turn-rate motion model.

The optional input x2 has the same size and data type as the output state vector or the state covariance matrix, x. The variable x2 does not contain the actual output state information, but only holds the size and the data type of the output state. For example, when x2 is set to [0;0;0;0;0;0;0], the function determines the output state vector to be a vector of size 7 with a data type of double.

The size of the state vector must fit the motion model. For example, if the modelType is 'constvel', the state vector must be of size 2, 4, or 6. Similarly, if the modelType is 'constacc', the state vector must be of size 3, 6, or 9. The relationship between model type, state size, and the space dimension is given by the following table:

modelType1Supported Space DimensionState size
'constvel'1-D, 2-D, 3-D

2 ✕ Space dimension

'constacc'1-D, 2-D, 3-D

3 ✕ Space dimension

'constturn'2-D and 3-D

5 for 2-D space and 7 for 3-D space

Example: [0;0;0;0;0;0;0]

Data Types: single | double

Output Arguments

collapse all

State vector or state covariance matrix, corresponding to the motion model specified in modelType2.

The relationship between model type, state size, and the space dimension is given by the following table:

modelType1Supported Space DimensionState size
'constvel'1-D, 2-D, 3-D

2 ✕ Space dimension

'constacc'1-D, 2-D, 3-D

3 ✕ Space dimension

'constturn'2-D and 3-D

5 for 2-D space and 7 for 3-D space

If x2 is not specified:

Given modelType1 and x1, the function determines the input state dimension based on the relationship specified in the table. For example, if modelType1 is 'constvel', and x1 is a 4-by-1 vector, the input state dimension is given by 4/2, which equals 2.

If modelType1 is 'constacc' and x1 is a 6-by-1 vector, the input state dimension is given by 6/3, which equals 2.

In this case when x2 is not specified, the output x has the same data type as x1 and the dimension is calculated using modelType1 and x1.

If x2 is specified:

The function calculates the output space dimnension using modelType2 and x2. For example, if modelType2 is 'constacc' and x2 is a 6-by-1 vector, the output state dimension is given by 6/3, which equals 2.

The output x has the same data type and dimensionality as x2.

Extended Capabilities

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

See Also

Objects

Functions

Introduced in R2018b