| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |

| On this page… |
|---|
Save complete SimState in final state |
The Data Import/Export pane allows you to import input signal and initial state data from a workspace and export output signal and state data to the MATLAB® workspace during simulation. This capability allows you to use standard or custom MATLAB functions to generate a simulated system's input signals and to graph, analyze, or otherwise postprocess the system's outputs.
Specify the data to load from a workspace before simulation begins.
Specify the data to save to the MATLAB workspace after simulation completes.
For more information on using this pane, see Importing and Exporting Simulation Data.
See the documentation of the sim command for some capabilities that are available only for programmatic simulation.
Loads input data from a workspace before the simulation begins.
Default: Off, [t,u]
Loads data from a workspace.
Specify a MATLAB expression for the data to be imported from a workspace. The Simulink software resolves symbols used in this specification as described in Resolving Symbols. The input data can take any of the following forms:
Time series
Data array
Time expression
Data structure
See Importing Data from a Workspace for information on how to use this field.
Does not load data from a workspace.
You must select the Input check box before entering input data.
Simulink software linearly interpolates or extrapolates input values as necessary if the Interpolate data option is selected for the corresponding Inport.
The use of the Input box is independent of the setting of the Format list on the Data Import/Export pane.
Limitation: You cannot load fixed-point data that is contained in a structure. Consider using a Simulink.Timeseries object instead of a structure.
| Parameter: LoadExternalInput |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Parameter: ExternalInput |
| Type: scalar or vector |
| Value: any valid value |
| Default: [t,u] |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Loads the model's initial states from a workspace before simulation begins.
Default: Off, xInitial
Simulink software loads initial states from a workspace.
Specify the name of a variable that contains the initial state values, for example, a variable containing states saved from a previous simulation.
Use the structure or structure-with-time option to specify initial states if you want to accomplish any of the following:
Associate initial state values directly with the full path name to the states. This eliminates errors that could occur if Simulink software reorders the states, but the initial state array is not correspondingly reordered.
Assign a different data type to each state's initial value.
Initialize only a subset of the states.
See Importing and Exporting States for more information.
Simulink software does not load initial states from a workspace.
You must select the Initial State check box before entering initial state data.
The initial values specified by the workspace variable override the initial values specified by the model itself (the values specified by the initial condition parameters of those blocks in the model that have states).
You must use the structure or structure-with-time format to initialize the states of a top model and the models that it references.
| Parameter: LoadInitialState |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Parameter: InitialState |
| Type: variable (string) or vector |
| Value: any valid value |
| Default: 'xInitial' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Saves simulation time data to the specified variable during simulation.
Default: On, tout
Simulink software exports time data to the MATLAB workspace during simulation.
Specify the name of the MATLAB variable used to store time data. See Exporting Data to the MATLAB Workspace for more information.
Simulink software does not export time data to the MATLAB workspace during simulation.
You must select the Time check box before entering the time variable.
Simulink software saves the output to the MATLAB workspace at the base sample rate of the model. Use a To Workspace block if you want to save output at a different sample rate.
The Save options area enables you to specify the format and restrict the amount of output saved.
| Parameter: SaveTime |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'on' |
| Parameter: TimeSaveName |
| Type: string |
| Value: any valid value |
| Default: 'tout' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Saves state data to the specified MATLAB variable during a simulation.
Default: Off, xout
Simulink software exports state data to the MATLAB workspace during simulation.
Specify the name of the MATLAB variable used to store state data. See Importing and Exporting States for more information.
Simulink software does not export state data during simulation.
You must select the States check box before entering the states variable.
Simulink software saves the states in a MATLAB workspace variable having the specified name.
The saved data has the format that you specify in the Save options area.
| Parameter: SaveState |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Parameter: StateSaveName |
| Type: string |
| Value: any valid value |
| Default: 'xout' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Saves signal data to the specified MATLAB variable during simulation.
Default: On, yout
Simulink software exports signal data to the MATLAB workspace during simulation.
Specify the name of the MATLAB variable used to store signal data. See Exporting Data to the MATLAB Workspace for more information.
Simulink software does not export signal data during simulation.
You must select the Output check box before entering the output variable.
Simulink software saves the output to the MATLAB workspace at the base sample rate of the model. Use a To Workspace block if you want to save output at a different sample rate.
The Save options area enables you to specify the format and restrict the amount of output saved.
| Parameter: SaveOutput |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'on' |
| Parameter: OutputSaveName |
| Type: string |
| Value: any valid value |
| Default: 'yout' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Saves the model's logged states at the end of a simulation to the specified MATLAB variable.
Default: Off, xFinal
Simulink software exports final logged state data to the MATLAB workspace during simulation.
Specify the name of the MATLAB variable in which to store the values of these final states. See Importing and Exporting States for more information.
Simulink software does not export the final state data during simulation.
You must select the Final states check box before entering the final states variable.
Simulink software saves the final states in a MATLAB workspace variable having the specified name.
The saved data has the format that you specify in the Save options area.
| Parameter: SaveFinalState |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Parameter: FinalStateName |
| Type: string |
| Value: any valid value |
| Default: 'xFinal' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
At the end of a simulation, Simulink saves the complete set of states of the model, including logged states, to the specified MATLAB variable.
Default: Off, xFinal
Simulink software exports the complete set of final state data (i.e., the SimState) to the MATLAB workspace during simulation.
Specify the name of the MATLAB variable in which to store the values of the final states. See Importing and Exporting States for more information.
Simulink software exports the final logged states during simulation.
You must select the Final states check box to enable the Save complete SimState in final state option.
Simulink saves the final states in a MATLAB workspace variable having the specified name.
The saved data has the format that you specify in the Save options area.
This parameter is enabled by Final states.
| Parameter: SaveCompleteFinalSimState |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Parameter: FinalStateName |
| Type: string |
| Value: any valid value |
| Default: 'xFinal' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
Globally enable or disable signal logging for this model.
Default: On, logsout
Enables signal logging to the MATLAB workspace during simulation.
Specify the name of the signal logging object used to record logged signal data in the MATLAB workspace. See Logging Signals for more information.
Disables signal logging to the MATLAB workspace during simulation.
You must select the Signal logging check box before entering the signal logging variable.
Simulink software saves the signal data in a MATLAB workspace variable having the specified name.
The saved data has the format that you specify in the Save options area.
Simulink software does not support signal logging for the following types of signals:
Output of a Function-Call Generator block
Signal connected to the input of a Merge block
Outputs of Trigger and Enable blocks
This parameter enables Inspect signal logs when simulation is paused/stopped.
| Parameter: SignalLogging |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'on' |
| Parameter: SignalLoggingName |
| Type: string |
| Value: any valid value |
| Default: 'logsOut' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Specify whether Simulink software displays logged signals in the MATLAB Time Series Tools viewer at the end of a simulation or whenever you pause the simulation.
Default: Off
Simulink software displays logged signals in the MATLAB Time Series Tools viewer at the end of a simulation or whenever you pause the simulation.
Simulink software does not display logged signals at the end of a simulation.
If this option is off, you must select Tools > Inspect logged signals in the model editor to display logged signals in the Time Series Tools viewer.
You must run the simulation before selecting Tools > Inspect logged signals. Otherwise, the command has no effect.
This parameter is enabled by Signal logging.
| Parameter: InspectSignalLogs |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'off' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Specify the number of data points exported to the MATLAB workspace be limited to the number specified.
Default: On, 1000
Limits the number of data points exported to the MATLAB workspace to the number specified.
Specify the maximum number of data points exported to the MATLAB workspace. At the end of the simulation, the MATLAB workspace contains the last N points generated by the simulation.
Does not limit the number of data points.
You must select the Limit data points to last check box before specifying the number of data points.
Saving data to the MATLAB workspace can slow down the simulation and consume memory. Use this parameter to limit the number of samples saved to help avoid this problem.
You can also apply a Decimation factor to skip a selected number of samples.
| Parameter: LimitDataPoints |
| Type: string |
| Value: 'on' | 'off' |
| Default: 'on' |
| Parameter: MaxDataPoints |
| Type: string |
| Value: any valid value |
| Default: '1000' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Specify that Simulink software output only every N points, where N is the specified decimation factor.
Default: 1
The default value (1) specifies that all data points are saved.
Simulink software outputs data only at the specified number of data points. For example, specifying 2 saves every other data point, while specifying 10 saves just one in ten data points.
At the end of the simulation, the total number of data points is reduced by the factor specified.
Saving data to the MATLAB workspace can slow down the simulation and consume memory. Use this parameter to limit the number of samples saved to help avoid this problem.
You can also use the Limit data points to last parameter to help resolve this problem.
| Parameter: Decimation |
| Type: string |
| Value: any valid value |
| Default: '1' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Select the format of state and output data saved to the MATLAB workspace.
Default: Array
The format of the data is a matrix each row of which corresponds to a simulation time step.
The format of the data is a structure that contains substructures for each port. Each port substructure contains signal data for the corresponding port.
The format of the data is a structure that has two fields: a time field and a signals field. The time field contains a vector of simulation times. The signals field contains a substructure for each model input port (for imported data) or output port (for exported data). Each port substructure contains signal data for the corresponding port.
You can use array format to save your model's outputs and states only if the outputs are either all scalars or all vectors (or all matrices for states), are either all real or all complex, and are all of the same data type. Use the Structure or Structure with time output formats (see Structure with time) if your model's outputs and states do not meet these conditions.
Simulink software can read back simulation data saved to the workspace in the Structure with time output format. See Importing Signal-and-Time Data Structures for more information.
| Parameter: SaveFormat |
| Type: string |
| Value: 'Array' | 'Structure' | 'StructureWithTime' |
| Default: 'Array' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Select options for generating additional output signal data for variable-step solvers.
Default: Refine output
Generates data output between as well as at simulation times steps. Use Refine factor to specify the number of points to generate between simulation time steps. For more information, see Refining Output.
Generates additional output at specified times. Use Output times to specify the simulation times at which Simulink software should generate additional output.
Generates output only at specified times. Use Output times to specify the simulation times at which Simulink software should generate output.
These settings can force the solver to calculate output values for times that it would otherwise have omitted because the calculations were not needed to achieve accurate simulation results. These extra calculations can cause the solver to locate zero crossings that it would otherwise have missed.
For additional information on how Simulink software calculates outputs for these three options, see Specifying Output Options.
This parameter is enabled only if the model specifies a variable-step solver (see Solver Type).
Selecting Refine output enables the Refine factor parameter.
Selecting Produce additional output or Produce specified output only enables the Output times parameter.
| Parameter: OutputOption |
| Type: string |
| Value: 'RefineOutputTimes' | 'AdditionalOutputTimes' | 'SpecifiedOutputTimes' |
| Default: 'RefineOutputTimes' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Specify how many points to generate between time steps to refine the output.
Default: 1
The default refine factor is 1, meaning that no extra data points are generated.
A refine factor of 2 provides output midway between the time steps, as well as at the steps.
Simulink software ignores this option for discrete models. This is because the value of data between time steps is undefined for discrete models.
This parameter is enabled only if you select Refine output as the value of Output options.
| Parameter: Refine |
| Type: string |
| Value: any valid value |
| Default: '1' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Specify times at which Simulink software should generate output in addition to, or instead of, the times of the simulation steps taken by the solver used to simulate the model.
Default: []
Enter a matrix containing the times at which Simulink software should generate output in addition to, or instead of, the simulation steps taken by the solver.
If the value of Output options is Produce additional output, the default value [] specifies that no additional data points are generated.
If the value of Output options is Produce specified output only, the default value [] specifies that no data points are generated.
The Produce additional output option generates output at the specified times as well as the regular simulation steps.
The Produce specified output only option generates output only at the specified times.
Discrete models define outputs only at major time steps. Therefore, Simulink software logs output for discrete models only at major time steps. If the Output times field specifies other times, Simulink software displays a warning at the MATLAB command line.
This parameter is enabled only if the value of Output options is Produce additional output or Produce specified output only.
| Parameter: OutputTimes |
| Type: string |
| Value: any valid value |
| Default: '[]' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact for simulation and during development Off for production code generation |
Enable the single-output format of the sim command.
Default: off
Turning this option 'on' directs Simulink to return all simulation outputs within a single Simulink.SimulationOutput object.
Enabling this option makes the sim command compatible with the parfor command, in terms of transparency issues.
The method who of the Simulink.SimulationOutput object returns the list of variables that the object contains.
Use the find method of the Simulink.SimulationOutput object to access the variables that the object contains.
| Parameter: ReturnWorkspaceOutputs |
| Type: string |
| Value: 'on' | 'off' | |
| Default: 'off' |
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No impact |
| Safety precaution | No impact |
![]() | Solver Pane | Optimization Pane | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |