Simulink.SimulationData.State - Container for state logging information - MATLAB (original) (raw)
Main Content
Container for state logging information
Description
The software uses Simulink.SimulationData.State
objects to store state logging information during simulation.Simulink.SimulationData.State
objects contain information about the source block the state data is coming from and the type of state.
Creation
Simulating a model that logs state data creates one or moreSimulink.SimulationData.State
objects.
Syntax
Description
`st` = Simulink.SimulationData.State
creates an empty Simulink.SimulationData.State
object.
Properties
Name of State
object to use for name-based access, specified as a string or character vector.
When you create an empty State
object and do not specify a name, no name is assigned.
When a State
object is created during simulation, theName property of the State
object is specified by the State name parameter of the block from which state information is logged. Some blocks in the Discrete library, such as the Unit Delay block, automatically name the State
object DSTATE
when theState name parameter of the block is empty.
Block path of source block for State
object, specified as a Simulink.SimulationData.BlockPath
object.
This property is read-only.
Type of state, returned as one of these values:
'CSTATE'
– Continuous state'DSTATE'
– Discrete state
Logged time and data, specified as one of these values:
- A MATLAB®
timeseries
object - A MATLAB
timetable
object - A structure of MATLAB
timeseries
objects (for bus signals) - A structure of MATLAB
timetable
objects (for bus signals) - An array of structures of MATLAB
timeseries
objects (for array of buses signals) - An array of structures of MATLAB
timetable
objects (for array of buses signals) - An array of MATLAB
timeseries
objects (for nonbus signals in a For Each subsystem) - A cell array of MATLAB
timetable
objects (for nonbus signals in a For Each subsystem)
Object Functions
plot | Plot data in Simulation Data Inspector |
---|
Examples
You can save final state information using the Dataset
format and access the state data after simulation.
Load the model vdp
and configure the model to log final states using the Dataset
format. This example uses the default final states variable name xFinal
.
mdl = "vdp"; load_system(mdl); set_param(mdl,"SaveFinalState","on","SaveFormat","Dataset");
Simulate the model. By default, all logged data is returned in the single variable out
as a Simulink.SimulationOutput
object. Final state information is stored in the SimulationOutput
object as a Simulink.SimulationData.Dataset
object named xFinal
.
out = Simulink.SimulationOutput:
logsout: [1x1 Simulink.SimulationData.Dataset]
tout: [87x1 double]
xFinal: [1x1 Simulink.SimulationData.Dataset]
yout: [1x1 Simulink.SimulationData.Dataset]
SimulationMetadata: [1x1 Simulink.SimulationMetadata]
ErrorMessage: [0x0 char]
Get the xFinal
Dataset
object from the SimulationOutput
object. The xFinal
Dataset
object contains data for two states.
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 State
object that corresponds to the x1
signal.
state_x1 = Simulink.SimulationData.State Package: Simulink.SimulationData
Properties: Name: '' BlockPath: [1×1 Simulink.SimulationData.BlockPath] Label: CSTATE Values: [1×1 timeseries]
Methods, Superclasses
Version History
Introduced in R2015a