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
Name
— Name of state element to use for name-based access
character vector
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.
BlockPath
— Block path for state source block
a Simulink.SimulationData.BlockPath
object
Block path for state source block, specified as a Simulink.SimulationData.BlockPath
object
Label
— Type of state
'CSTATE'
| 'DSTATE'
Type of state, returned as 'CSTATE'
or 'DSTATE'
.
Read-only property.
'CSTATE'
– Continuous state'DSTATE'
– Discrete state
Values
— State element information
single MATLAB® timeseries
object | a structure of MATLAB timeseries
objects
State element information, specified as a single MATLAB timeseries
object
or as a structure of MATLAB timeseries
objects.
Methods
plot | Plot data in Simulation Data Inspector |
Examples
Access Final State Information Saved Using Dataset
Format
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.
out = sim(mdl);
By default, models create a single simulation output that contains all logged data in a Simulink.SimulationOutput
object. Get the xFinal
Dataset
object from the SimulationOutput
object. The xFinal
Dataset
object contains data for two states.
xFinal = get(out,"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 data for the state that corresponds to the x1
block.
state_x1 = get(xFinal,1)
state_x1 = Simulink.SimulationData.State Package: Simulink.SimulationData Properties: Name: '' BlockPath: [1x1 Simulink.SimulationData.BlockPath] Label: CSTATE Values: [1x1 timeseries]
Version History
Introduced in R2015a
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)