# interpolate

Interpolate between states

## Syntax

``interpStates = interpolate(space,state1,state2,ratio)``

## Description

example

````interpStates = interpolate(space,state1,state2,ratio)` returns the states interpolated from `state1` and `state2` based on the specified `ratio`.```

## Examples

collapse all

Create an SE2 state space.

`space = stateSpaceSE2`
```space = stateSpaceSE2 with properties: Name: 'SE2' StateBounds: [3x2 double] NumStateVariables: 3 WeightXY: 1 WeightTheta: 0.1000 ```
` `

Interpolate half-way between 2 states.

`state = interpolate(space, [2 10 -pi], [0 -2.5 -pi/4], 0.5)`
```state = 1×3 1.0000 3.7500 -1.9635 ```
` `

Interpolate multiple points with a fixed interval.

`states = interpolate(space, [2 10 -pi], [0 -2.5 -pi/4], [0:0.02:1])`
```states = 51×3 2.0000 10.0000 -3.1416 1.9600 9.7500 -3.0945 1.9200 9.5000 -3.0473 1.8800 9.2500 -3.0002 1.8400 9.0000 -2.9531 1.8000 8.7500 -2.9060 1.7600 8.5000 -2.8588 1.7200 8.2500 -2.8117 1.6800 8.0000 -2.7646 1.6400 7.7500 -2.7175 ⋮ ```

## Input Arguments

collapse all

State space object, specified as a `stateSpaceSE2`, a `stateSpaceDubins`, or a `stateSpaceReedsShepp` object.

Data Types: `object`

Start state for interpolation, specified as a 3-element real vector.

Data Types: `single` | `double`

End state for interpolation, specified as a 3-element real vector.

Data Types: `single` | `double`

Interpolation ratio, specified as a scalar in `[0,1]`, or an N-by-1 array of scalars in [0,1] . N is the number of interpolation points.

Data Types: `single` | `double`

## Output Arguments

collapse all

Interpolated states, returned as an N-by-3 real-valued matrix. N is the number of interpolation points specified by the `ratio` input.

Data Types: `single` | `double`