Main Content

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

    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)

    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)

    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.4761
       -0.3816
       -0.2748
    
    
    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