Single simulation output
R2026bOption to return simulation results as single
Simulink.SimulationOutput object
Model Configuration Pane: Data Import/Export
Description
The Single simulation output parameter provides an option to always
return simulation results as a single Simulink.SimulationOutput object. Using the single-output format makes
processing results from multiple simulations easier and provides better support for
parallel and batch simulations. When you enable the Single simulation
output parameter, you can use the same code to process results, no matter
how you run the simulation.
The Single simulation output parameter affects how results are returned for:
Simulations run from a user interface, such as the Simulink Editor
Simulations run by specifying the name of the model as the only input to the sim function, except when fast restart is enabled
Even if you clear Single simulation output, the simulation returns results as a single output for simulations run:
Using the Multiple Simulations panel
By specifying one or more
Simulink.SimulationInputobjects as input to thesim,parsim, orbatchsimfunctionUsing a
SimulationobjectBy specifying the name of the model and one or more additional arguments as input to the
simfunctionBy specifying the name of the model as the only input to the
simfunction when fast restart is enabled in the model
Settings
on (default) | offonAll simulation data logged to the workspace is returned as a single
Simulink.SimulationOutputobject. By default, the name of the variable that stores theSimulink.SimulationOutputobject isout. To use a different variable name, specify a valid MATLAB® variable name in the text box.When you simulate a model programmatically, the name of the variable to which you assign the return argument overrides the name you specify in the text box. The
Simulink.SimulationOutputobject is stored in the variable to which you assign the return argument. For example, for this simulation,simoutis the name of the variable that stores the single simulation output.simout = sim(simin);
offLogged simulation results are returned as one or more variables, depending on the logging options configured in the model and how you run the simulation.
The
simfunction returns a vector of the simulation time steps if the only input argument is the name of the model and fast restart is disabled. To ensure simulations return results in a consistent format, save the model with the Single simulation output parameter enabled. Alternatively, specify the parameter as a name-value argument for thesimfunction.out = sim(mdl,ReturnWorkspaceOutputs="on");Syntaxes of the
simfunction that return multiple arguments are not recommended. For more information, see Syntaxes that return multiple output arguments are not recommended.
Examples
Tips
When you log data using the To File block, the data logs to the specified file and does not appear in the single
Simulink.SimulationOutputobject.When you select Log data to file, the
Simulink.SimulationOutputobject does not include data that logs to the file.Results returned as a single simulation output are not available when the
StopFcnmodel callback executes. To process simulation results, use thePostSimFcncallback of theSimulink.SimulationInputobject instead.To view a list of the variables in a
Simulink.SimulationOutputobject, use thewhofunction.To use the Logging intervals parameter, you must select Single simulation output.
Programmatic Use
Parameter: ReturnWorkspaceOutputs |
| Type: string | character vector |
Value:
"on" | "off" |
Default:
'on' |
Parameter: ReturnWorkspaceOutputsName |
| Type: string | character vector |
| Value: valid MATLAB variable name |
Default:
'out' |
Version History
Introduced in R2009b



