Simulink.SimulationData.State class

Package: Simulink.SimulationData
Superclasses:

State logging element

Description

Simulink® uses Simulink.SimulationData.State objects to store state logging information during simulation. The objects contain state information about which block the state data is coming from and the type of state.

Properties

expand all

Name of state element to use for name-based access, specified as a character vector. If you do not specify a name, 'CSTATE' or 'DSTATE' is used, depending on whether it a continuous or discrete state.

Block path for state source block, specified as a Simulink.SimulationData.BlockPath object

Type of state, returned as 'CSTATE' or 'DSTATE'. Read-only property.

  • 'CSTATE' – Continuous state

  • 'DSTATE' – Discrete state

State element information, specified as a single MATLAB timeseries object or as a structure of MATLAB timeseries objects.

Methods

plotPlot simulation output data in the Simulation Data Inspector

Examples

collapse all

Saved final state information in Dataset format and access the state data after simulation.

Open the vdp model and specify to log final states in Dataset format. Use the default logged state variable, xFinal.

open_system('vdp');
set_param(gcs,'SaveFinalState','on','SaveFormat','Dataset');

Simulate the vdp model.

sim('vdp');

View the state logging information in xFinal.

xFinal
xFinal = 

Simulink.SimulationData.Dataset 'xFinal' with 2 elements

                        Name  BlockPath 
                        ____  _________ 
    1  [1x1 State]      ''    vdp/x1   
    2  [1x1 State]      ''    vdp/x2   

  - Use braces { } to access, modify, or add elements using index.

Examine the first element of the state dataset.

xFinal.get(1)
ans = 

  Simulink.SimulationData.State
  Package: Simulink.SimulationData

  Properties:
         Name: ''
    BlockPath: [1×1 Simulink.SimulationData.BlockPath]
        Label: CSTATE
       Values: [1×1 timeseries]


Introduced in R2015a