Simulink.SimulationOutput class

Package: Simulink

Access object values of simulation results


The SimulationOutput class contains all simulation outputs, including workspace variables.

You can use dot notation to access the data for simulation outputs. For example, to return data for the xout variable for a simOut, SimulationOutput object, use a simOut.tout command.

Alternatively, you can use Simulink.SimulationOutput.who and either Simulink.SimulationOutput.get or Simulink.SimulationOutput.find methods to access the output variable names and their respective values.

The SimulationOutput object is writeable. You can write to logsout and yout in SimulationOutput object.

You can use the plot function to plot the SimulationOutput output.



expand all

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

Simulation logging error message, returned as a char vector. (read only)


find Access and display values of simulation results
get Access and display values of simulation results
getSimulationMetadataReturn SimulationMetadata object for simulation
plotPlot simulation output data in the Simulation Data Inspector
setUserDataStore custom data in SimulationMetadata object that SimulationOutput object contains
setUserStringStore custom character vector in SimulationMetadata object that SimulationOutput object contains
who Access and display output variable names of simulation

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects (MATLAB) in the MATLAB® Programming Fundamentals documentation.


collapse all

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

Simulate the vdp model.

simOut = sim('vdp','SimulationMode','normal','AbsTol','1e-5',...

                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