Main Content

Simulink.SimulationOutput

Access simulation results

Description

TheSimulink.SimulationOutputobject includes all logged simulation data and aSimulationMetadataobject that describes simulation conditions. TheSimulink.SimulationOutputobject also contains useful metadata about the simulation, simulation run time. You can use theSimulink.SimulationOutputobject to inspect results of the simulation, and you can use theplotfunction on theSimulink.SimulationOutputobject to visualize the results. For simulation invoked using theRunorStep Forwardbuttons in Simulink, theSimulink.SimulationOutputobject is stored in the base workspace, with the name specified in the model parameters.Simulink.SimulationOutputis writeable.

Creation

By default, each simulation you run, creates aSimulink.SimulationOutputobject that contains all data logged in the simulation, and aSimulink.SimulationMetadataobject with the simulation metadata. You can access theSimulationOutputobjects in several ways.

  • TheSimulink.SimulationOutputobject returns the logged data for the simulation.

  • You can usewho,get, andfind方法访问输出variable names and their respective values.

In theConfiguration Parameters, the model settingSingle simulation output, controls whether simulation output is returned in aSimulink.SimulationOutputobject or if data is expanded in the base workspace. You can also use the command line API for this behavior by settingReturnWorkspaceOutputstoonas a name-value argument pair with thesimcommand.

Properties

expand all

Metadata for simulations, returned as aSimulink.SimulationMetadataobject. Fields other than theUserDataandUserStringfields are read-only.

This property is read-only.

Simulation logging error messages returned as a character vector. TheErrorMessageproperty is empty when the simulation runs without errors.

Object Functions

find Access and display values of simulation results
get Access and display values of simulation results
getSimulationMetadata ReturnSimulationMetadata为模拟对象
setUserData Store custom data inSimulationMetadataobject thatSimulationOutputobject contains
setUserString Store custom character vector inSimulationMetadataobject inSimulationOutputobject
who Access and display output variable names of simulation
plot Plot simulation output data in the Simulation Data Inspector

Examples

collapse all

Simulate a model, place the results of theSimulink.SimulationOutputobject insimOutand view the simulation metadata.

Simulate thevdpmodel.

simOut = sim('vdp','SaveState','on','StateSaveName','xoutNew',...'SaveOutput','on','OutputSaveName','youtNew')
Simulink.SimulationOutput: xoutNew: [65x2 double] youtNew: [65x2 double] SimulationMetadata: [1x1 Simulink.SimulationMetadata] ErrorMessage: [0x0 char]

Get the values of the variableyoutNew.

simOut.youtNew

万博1manbetx®returns and displays the values.

Get the timing information for the simulation.

myMetadata = simOut.SimulationMetadata
myMetadata = SimulationMetadata with properties: ModelInfo: [1×1 struct] TimingInfo: [1×1 struct] ExecutionInfo: [1×1 struct] UserString: '' UserData: []
myMetadata.TimingInfo
ans = struct with fields: WallClockTimestampStart: '2016-12-30 08:47:51.739935' WallClockTimestampStop: '2016-12-30 08:47:58.185579' InitializationElapsedWallTime: 5.9166 ExecutionElapsedWallTime: 0.1910 TerminationElapsedWallTime: 0.3380 TotalElapsedWallTime: 6.4456

版本历史

Introduced in R2010a