Package: Simulink
Superclasses:
Access metadata of simulation runs
The SimulationMetadata
class contains information
about a simulation run including:
Model information
Timing information
Execution and diagnostic information
Custom character vector to tag the simulation
Custom data to describe the simulation
SimulationMetadata
packages this
information with the SimulationOutput
object. To
use SimulationMetadata
, use one of these approaches:
In Configuration Parameters > Data Import/Export, under Save options, select Single simulation output.
Use set_param
to set ReturnWorkspaceOutputs
to on
.
set_param(model_name,'ReturnWorkspaceOutputs','on');
To retrieve the SimulationMetadata
object,
use the getSimulationMetadata
method on a SimulationOutput
object.
ModelInfo
— Information about the model and simulation operating environmentThe ModelInfo
structure has these fields.
Field Name | Type | Description |
---|---|---|
ModelName | char | Name of the model |
ModelVersion | char | Version of the model |
ModelFilePath | char | Absolute location of the .mdl /.slx file |
UserID | char | System user ID of the machine used for the simulation |
MachineName | char | Hostname of the machine used for the simulation |
Platform | char | Operating system of the machine used for the simulation |
ModelStructuralChecksum | 4–by–1 uint32 | Structural checksum of the model calculated after an update diagram |
SimulationMode | char | Simulation mode |
StartTime | double | Simulation start time |
StopTime | double | Time at which the simulation was terminated |
SolverInfo | structure | Solver information:
|
SimulinkVersion | structure | Version of Simulink® |
LoggingInfo | structure | Metadata about logging to persistent storage:
|
ExecutionInfo
— Structure to store information about a simulation runStructure to store information about a simulation run, including the reason a simulation stopped and any diagnostics reported during the simulation. The structure has these fields.
Field Name | Type | Description |
---|---|---|
StopEvent | Nontranslated character vector | Reason the simulation stopped, represented by one of the following:
|
StopEventSource | Simulink.SimulationData.BlockPath | Source of stop event, if it is a valid Simulink object. |
StopEventDescription | Translated character vector | Superset of information stored in StopEvent and
StopEventSource . |
ErrorDiagnostic | struct | Error reported during simulation, represented by the following fields:
By passing the name–value pair
|
WarningDiagnostics | Array of struct | Array of all warnings reported during the simulation. Each array item is represented by the
following fields:
|
TimingInfo
— Structure to store profiling information about the simulationStructure to store profiling information about the simulation, including the time stamps for the start and end of the simulation. The structure has these fields.
Field Name | Type | Description |
---|---|---|
WallClockTimestampStart | character vector | Wall clock time when the simulation started, in YYYY-MM-DD
HH:MI:SS format with microsecond resolution |
WallClockTimestampStop | character vector | Wall clock time when the simulation stopped, in YYYY-MM-DD
HH:MI:SS format with microsecond resolution |
InitializationElapsedWallTime | double | Time spent before execution, in seconds |
ExecutionElapsedWallTime | double | Time spent during execution, in seconds |
TerminationElapsedWallTime | double | Time spent after execution, in seconds |
TotalElapsedWallTime | double | Total time spent in initialization, execution, and termination, in seconds |
ProfilerData | Simulink.profiler.Data | Profiling results of the model, returned as a
Note The |
The ExecutionElapsedWallTime
includes the
time that Simulink spent to roll back or step back in a simulation.
The ExecutionElapsedWallTime
does not include the
time spent between steps. For example, if you use Stepper to step
through a simulation, the ExecutionElapsedWallTime
time
does not include the time when the simulation is in a paused state.
For more information about using Stepper, see How Simulation Stepper Helps With Model Analysis.
UserString
— Custom character vector to describe the simulationUse Simulink.SimulationOutput.setUserString
to
directly store a character vector in the SimulationMetadata
object
that is contained in the SimulationOutput
object.
UserData
— Custom data to store in SimulationMetadata
object that is contained in the SimulationOutput
objectUse Simulink.SimulationOutput.setUserData
to
store custom data in the SimulationMetadata
object
that is contained in the SimulationOutput
object.
Value. To learn how value classes affect copy operations, see Copying Objects.
Simulate the vdp
model. Retrieve metadata from a SimulationMetadata
object of the simulation.
Simulate the vdp
model. Save the results of the Simulink.SimulationOutput
object in simout
.
open_system('vdp'); simout = sim(bdroot,'ReturnWorkspaceOutputs','on');
Retrieve metadata information about this simulation using mData
. This is the SimulationMetadata
object that simout
contains.
mData=simout.getSimulationMetadata()
mData = SimulationMetadata with properties: ModelInfo: [1x1 struct] TimingInfo: [1x1 struct] ExecutionInfo: [1x1 struct] UserString: '' UserData: []
Store custom data or string in simout
.
simout=simout.setUserData(struct('param1','value1','param2','value2','param3','value3')); simout=simout.setUserString('Store first simulation results');
Retrieve the custom data you stored from mData
.
mData=simout.getSimulationMetadata() disp(mData.UserData)
mData = SimulationMetadata with properties: ModelInfo: [1x1 struct] TimingInfo: [1x1 struct] ExecutionInfo: [1x1 struct] UserString: 'Store first simulation results' UserData: [1x1 struct] param1: 'value1' param2: 'value2' param3: 'value3'
Retrieve the custom string you stored from mData
.
mData=simout.getSimulationMetadata() disp(mData.UserString)
mData = SimulationMetadata with properties: ModelInfo: [1x1 struct] TimingInfo: [1x1 struct] ExecutionInfo: [1x1 struct] UserString: 'Store first simulation results' UserData: [1x1 struct] Store first simulation results
You have a modified version of this example. Do you want to open this example with your edits?