# constacc

State transition function for constant-acceleration motion model

## Syntax

``predictedState = constacc(state)``
``predictedState = constacc(state,dt)``
``predictedState = constacc(state,w,dt)``

## Description

````predictedState = constacc(state)` returns the predicted state, `predictedState`, obtained from the current state, `state`, based on the constant-acceleration motion model. The default time step is 1 second.```

example

````predictedState = constacc(state,dt)` specifies the time step, `dt`.```

example

````predictedState = constacc(state,w,dt)` also specifies the state noise, `w`.```

## Examples

collapse all

Define an initial state for 2-D constant-acceleration motion.

`state = [1;1;1;2;1;0];`

Predict the state 1 second later.

`state = constacc(state)`
```state = 6×1 2.5000 2.0000 1.0000 3.0000 1.0000 0 ```

Define an initial state for 2-D constant-acceleration motion.

`state = [1;1;1;2;1;0];`

Predict the state 0.5 s later.

`state = constacc(state,0.5)`
```state = 6×1 1.6250 1.5000 1.0000 2.5000 1.0000 0 ```

## Input Arguments

collapse all

Current state for constant-acceleration motion, specified as a real-valued 3D-by-N matrix. D is the number of spatial degrees of freedom of motion and N is the number states. For each spatial degree of motion, the state vector, as a column of the `state` matrix, takes the form shown in this table.

Spatial DimensionsState Vector Structure
1-D`[x;vx;ax]`
2-D`[x;vx;ax;y;vy;ay]`
3-D`[x;vx;ax;y;vy;ay;z;vz;az]`

For example, `x` represents the x-coordinate, `vx` represents the velocity in the x-direction, and `ax` represents the acceleration in the x-direction. If the motion model is in one-dimensional space, the y- and z-axes are assumed to be zero. If the motion model is in two-dimensional space, values along the z-axis are assumed to be zero. Position coordinates are in meters. Velocity coordinates are in meters/second. Acceleration coordinates are in meters/second2.

Example: `[5;0.1;0.01;0;-0.2;-0.01;-3;0.05;0]`

Data Types: `double`

Time step interval, specified as a positive scalar. Time units are in seconds.

Example: `0.5`

Data Types: `single` | `double`

State noise, specified as a scalar or real-valued D-by-N matrix. D is the number of spatial degrees of freedom of motion and N is the number of state vectors. If specified as a scalar, the scalar value is expanded to a D-by-N matrix.

Data Types: `single` | `double`

## Output Arguments

collapse all

Predicted state, returned as a real-valued vector or real-valued matrix with same number of elements and dimensions as the input state vector.

## Algorithms

For a two-dimensional constant-acceleration process, the state transition matrix after a time step, T, is block diagonal:

`$\left[\begin{array}{c}{x}_{k+1}\\ v{x}_{k+1}\\ a{x}_{k+1}\\ {y}_{k+1}\\ v{y}_{k+1}\\ a{y}_{k+1}\end{array}\right]=\left[\begin{array}{cccccc}1& T& \frac{1}{2}{T}^{2}& 0& 0& 0\\ 0& 1& T& 0& 0& 0\\ 0& 0& 1& 0& 0& 0\\ 0& 0& 0& 1& T& \frac{1}{2}{T}^{2}\\ 0& 0& 0& 0& 1& T\\ 0& 0& 0& 0& 0& 1\end{array}\right]\left[\begin{array}{c}{x}_{k}\\ v{x}_{k}\\ a{x}_{k}\\ {y}_{k}\\ v{y}_{k}\\ a{y}_{k}\end{array}\right]$`

The block for each spatial dimension has this form:

`$\left[\begin{array}{ccc}1& T& \frac{1}{2}{T}^{2}\\ 0& 1& T\\ 0& 0& 1\end{array}\right]$`

## Version History

Introduced in R2017a