idNeuralStateSpace/evaluate

Evaluate a neural state-space system for a given set of state and input values and return state derivative (or next state) and output values

Since R2022b

Syntax

``[dxdt,y] = evaluate(nss,x)``
``[dxdt,y] = evaluate(nss,x,u)``
``[dxdt,y] = evaluate(nss,t,x)``
``[dxdt,y] = evaluate(nss,t,x,u)``
``[xNext,y] = evaluate(nss,x)``
``[xNext,y] = evaluate(nss,x,u)``
``[xNext,y] = evaluate(nss,t,x)``
``[xNext,y] = evaluate(nss,tx,u)``

Description

Continuous-time

example

````[dxdt,y] = evaluate(nss,x)` evaluates the state and output networks of the autonomous time-invariant neural state-space system `nss` at state `x`, and returns the time-derivative of the state `dxdt` and the output `y`.`[dxdt,y] = evaluate(nss,x,u)` evaluates the state and output networks of the time-invariant neural state-space system `nss` with input `u`.`[dxdt,y] = evaluate(nss,t,x)` evaluates the state and output networks of the autonomous time-varying neural state-space system `nss` at time `t`.`[dxdt,y] = evaluate(nss,t,x,u)` evaluates the state and output networks of the time-varying neural state-space system `nss` at time `t`.```

Discrete-time

example

````[xNext,y] = evaluate(nss,x)` evaluates the state and output networks of the autonomous time-invariant neural state-space system `nss` at state `x`, and returns the next state `xNext` and the output `y`.`[xNext,y] = evaluate(nss,x,u)` evaluates the state and output networks of the time-invariant neural state-space system `nss` with input `u`.`[xNext,y] = evaluate(nss,t,x)` evaluates the state and output networks of the autonomous time-varying neural state-space system `nss` at time `t`.`[xNext,y] = evaluate(nss,tx,u)` evaluates the state and output networks of the time-varying neural state-space system `nss` at time `t`.```

Examples

collapse all

Use `idNeuralStateSpace` to create a continuous-time neural state-space object with two states, one input, and outputs identical to states.

`nss = idNeuralStateSpace(2,NumInputs=1)`
```nss = Continuous-time Neural ODE in 2 variables dx/dt = f(x(t),u(t)) y(t) = x(t) + e(t) f(.) network: Deep network with 2 fully connected, hidden layers Activation function: Tanh g(.) network: Deep network with 0 fully connected, hidden layers Activation function: Variables: x1, x2 Status: Created by direct construction or transformation. Not estimated. ```

Define random state and input values.

`x = rand(2,1)`
```x = 2×1 0.6785 0.0557 ```
`u = rand(1)`
```u = 0.0341 ```

Evaluate the (untrained) state and output networks of `nss` at the defined state and input.

`[dxdt,y] = evaluate(nss,x,u)`
```dxdt = 2×1 -0.1448 0.1793 ```
```y = 2×1 0.6785 0.0557 ```

Note that the output is identical to the current state, as expected.

Use `idNeuralStateSpace` to create a discrete-time neural state-space object with three states, two inputs, four outputs, and sample time `0.1`.

`nss = idNeuralStateSpace(3,NumInputs=2,NumOutputs=4,Ts=0.1)`
```nss = Discrete-time Neural State-Space Model with 4 outputs, 3 states, and 2 inputs x(t+1) = f(x(t),u(t)) y_1(t) = x(t) + e_1(t) y_2(t) = g(x(t),u(t)) + e_2(t) y(t) = [y_1(t); y_2(t)] f(.) network: Deep network with 2 fully connected, hidden layers Activation function: Tanh g(.) network: Deep network with 2 fully connected, hidden layers Activation function: Tanh Inputs: u1, u2 Outputs: y1, y2, y3, y4 States: x1, x2, x3 Sample time: 0.1 seconds Status: Created by direct construction or transformation. Not estimated. ```

Define random state and input values.

`x = rand(3,1)`
```x = 3×1 0.9165 0.4326 0.4270 ```
`u = rand(2,1)`
```u = 2×1 0.0293 0.5104 ```

Evaluate the (untrained) state and output networks of `nss` at the defined state and input.

`[xNext,y] = evaluate(nss,x,u)`
```xNext = 3×1 0.4405 0.0511 0.1522 ```
```y = 4×1 0.9165 0.4326 0.4270 -0.4388 ```

Note that the first three outputs are the current states, as expected.

Input Arguments

collapse all

Neural state-space system, specified as an `idNeuralStateSpace` object.

Example: `myNrlSS`

Value of the time variable, specified as a scalar, for time-varying `idNeuralStateSpace` systems.

Example: 1.8

Value of the state, specified as a scalar or column vector.

Example: [-1.2 -0.3]'

Value of the input, specified as a scalar or column vector.

Example: 2.9

Output Arguments

collapse all

Value of the time-derivative of the state, returned as a scalar or column vector. This is obtained by evaluating the state network of the continuous-time `idNeuralStateSpace` system `nss`.

Example: [-1.2 -4.9 3.8]'

Value of the state at the next sample time, returned as a scalar or column vector. This is obtained by evaluating the state network of the discrete-time `idNeuralStateSpace` system `nss`.

Example: [0.69 0.31]'

Value of the output, returned as a scalar or column vector with as may elements as the total number of outputs. This is obtained by evaluating both output networks of the `idNeuralStateSpace` system `nss`. Note that the first nx elements of `y` are always equal to the elements of `x`, where nx is the number of states specified in `nss`.

Example: [2 -3.1]

Version History

Introduced in R2022b