Main Content


Access simulation results


The Simulink.SimulationOutput object includes all logged simulation data and a SimulationMetadata object that describes simulation conditions. The Simulink.SimulationOutput object also contains useful metadata about the simulation, simulation run time. You can use the Simulink.SimulationOutput object to inspect results of the simulation, and you can use the plot function on the Simulink.SimulationOutput object to visualize the results. For simulation invoked using the Run or Step Forward buttons in Simulink, the Simulink.SimulationOutput object is stored in the base workspace, with the name specified in the model parameters. Simulink.SimulationOutput is writeable.


By default, each simulation you run, creates a Simulink.SimulationOutput object that contains all data logged in the simulation, and a Simulink.SimulationMetadata object with the simulation metadata. You can access the SimulationOutput objects in several ways.

  • The Simulink.SimulationOutput object returns the logged data for the simulation.

  • You can use who, get, and find methods to access the output variable names and their respective values.

In the Configuration Parameters, the model setting Single simulation output, controls whether simulation output is returned in a Simulink.SimulationOutput object or if data is expanded in the base workspace. You can also use the command line API for this behavior by setting ReturnWorkspaceOutputs to on as a name-value argument pair with the sim command.


expand all

Metadata for simulations, returned as a Simulink.SimulationMetadata object. Fields other than the UserData and UserString fields are read-only.

This property is read-only.

Simulation logging error messages returned as a character vector. The ErrorMessage property 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
getSimulationMetadataReturn SimulationMetadata object for simulation
setUserDataStore custom data in SimulationMetadata object that SimulationOutput object contains
setUserStringStore custom character vector in SimulationMetadata object in SimulationOutput object
who Access and display output variable names of simulation
plotPlot simulation output data in the Simulation Data Inspector


collapse all

Simulate a model, place the results of the Simulink.SimulationOutput object in simOut and view the simulation metadata.

Simulate the vdp model.

simOut = sim('vdp','SaveState','on','StateSaveName','xoutNew',...

                xoutNew: [65x2 double] 
                youtNew: [65x2 double] 

     SimulationMetadata: [1x1 Simulink.SimulationMetadata] 
           ErrorMessage: [0x0 char] 

Get the values of the variable youtNew.


Simulink® 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: []
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

Version History

Introduced in R2010a