Documentation Center

  • Trials
  • Product Updates

Data Import/Export Pane

Data Import/Export Overview

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.

Configuration

  1. Specify the data to load from a workspace before simulation begins.

  2. Specify the data to save to the MATLAB workspace after simulation completes.

Tips

  • To open the Data Import/Export pane, in the Simulink® Editor, select Simulation > Model Configuration Parameters > Data Import/Export.

  • For more information importing and exporting data, see Import Data and Export Runtime Information.

  • See the documentation of the simsim command for some capabilities that are available only for programmatic simulation.

See Also

Input

Loads input data from a workspace before the simulation begins.

Settings

Default: Off, [t,u]

On

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 Symbol Resolution.

See Import Data to Root-Level Input Ports for information on how to use this field.

Off

Does not load data from a workspace.

Tips

  • 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.

Command-Line Information

Parameter: LoadExternalInput
Type: string
Value: 'on' | 'off'
Default: 'off'
Parameter: ExternalInput
Type: string
Value: any valid value
Default: '[t,u]'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Initial state

Loads the model's initial states from a workspace before simulation begins.

Settings

Default: Off, xInitial

On

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 Import and Export States for more information.

Off

Simulink software does not load initial states from a workspace.

Tips

  • You must select the Initial state check box before entering initial state data.

  • The initial values that the workspace variable specifies override the initial values that the model specifies (the values that the initial condition parameters of those blocks in the model that have states specify).

  • Use either the structure format or structure-with-time format to initialize the states of a top model and the models that it references.

  • Selecting the Initial state check box does not result in Simulink initializing discrete states in referenced models.

Command-Line Information

Parameter: LoadInitialState
Type: string
Value: 'on' | 'off'
Default: 'off'
Parameter: InitialState
Type: variable (string) or vector
Value: any valid value
Default: 'xInitial'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Time

Saves simulation time data to the specified variable during simulation.

Settings

Default: On, tout

On

Simulink software exports time data to the MATLAB workspace during simulation.

Specify the name of the MATLAB variable used to store time data. See Export Simulation Data for more information.

Off

Simulink software does not export time data to the MATLAB workspace during simulation.

Tips

  • 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 Time, State, Output area includes parameters for specifying a limit on the number of data points to export and the decimation factor.

Command-Line Information

Parameter: SaveTime
Type: string
Value: 'on' | 'off'
Default: 'on'
Parameter: TimeSaveName
Type: string
Value: any valid value
Default: 'tout'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

States

Saves state data to the specified MATLAB variable during a simulation.

Settings

Default: Off, xout

On

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 StatesImporting and Exporting States for more information.

Off

Simulink does not export state data during simulation.

Tips

  • You must select the States check box before entering the states variable.

  • Simulink saves the states in a MATLAB workspace variable having the specified name.

  • The saved data has the format that you specify with the Format parameter.

  • If you select the States check box, Simulink does not log fixed-point states.

  • Simulink creates empty variables for state logging (xout) if both of these conditions apply:

    • You enable States.

    • A model has no states.

  • See Import and Export States for more information.

Command-Line Information

Parameter: SaveState
Type: string
Value: 'on' | 'off'
Default: 'off'
Parameter: StateSaveName
Type: string
Value: any valid value
Default: 'xout'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Output

Saves signal data to the specified MATLAB variable during simulation.

Settings

Default: On, yout

On

Simulink software exports signal data to the MATLAB workspace during simulation.

Specify the name of the MATLAB variable used to store signal data. See Export Simulation Data for more information.

Off

Simulink software does not export signal data during simulation.

Tips

  • 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 Time, State, Output area includes parameters for specifying the format and other characteristics of the saved data (for example, the format for the saved data and the decimation factor).

  • If you select the Output check box, Simulink logs fixed-point data as double. To log fixed-point data, consider using one of these approaches:

    • Signal logging — Right-click the signal and in the Properties dialog box, select Log signal. For details, see Export Signal Data Using Signal Logging.

    • To File block

    • To Workspace block — In the To Workspace block parameters dialog box, enable the Log fixed-point data as a fi object parameter.

  • For multiple names, use a comma-separated list (for example, yout1, yout2).

Command-Line Information

Parameter: SaveOutput
Type: string
Value: 'on' | 'off'
Default: 'on'
Parameter: OutputSaveName
Type: string
Value: any valid value
Default: 'yout'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Final states

Saves the logged states of the model at the end of a simulation to the specified MATLAB variable.

Settings

Default: Off, xFinal

On

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 StatesImporting and Exporting States for more information.

Off

Simulink software does not export the final state data during simulation.

Tips

  • 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 with the Format parameter.

  • Simulink creates empty variables for final state logging (xfinal) if both of these conditions apply:

    • You enable Final states.

    • A model has no states.

  • See Import and Export States for more information.

Command-Line Information

Parameter: SaveFinalState
Type: string
Value: 'on' | 'off'
Default: 'off'
Parameter: FinalStateName
Type: string
Value: any valid value
Default: 'xFinal'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Format

Select the data format for saving states, output, and final states data.

Settings

Default: Array

Array

The format of the data is a matrix each row of which corresponds to a simulation time step.

Structure

For logging output, the format of the data is a structure that contains substructures for each port. Each port substructure contains signal data for the corresponding port. For logging states, the structure contains a substructure for each block that has a state.

Structure with time

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 same data as for the Structure format.

Tips

  • 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.

  • If you enable the Save complete SimState in final state parameter, then the format does not apply to final states data.

  • Simulink software can read back simulation data saved to the workspace in the Structure with time output format. See Import Data to Root-Level Input Ports for more information.

  • See State and Output Data Format.

  • To specify the format for signal logging data, use the Signal logging format parameter.

Command-Line Information

Parameter: SaveFormat
Type: string
Value: 'Array' | 'Structure' | 'StructureWithTime'
Default: 'Array'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Limit data points to last

Limit the number of data points to export to the MATLAB workspace.

Settings

Default: On, 1000

On

Limits the number of data points exported to the MATLAB workspace to the number that you specify.

Specify the maximum number of data points to export to the MATLAB workspace. At the end of the simulation, the MATLAB workspace contains the last N points generated by the simulation.

Off

Does not limit the number of data points.

Tips

  • 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.

Command-Line Information

Parameter: LimitDataPoints
Type: string
Value: 'on' | 'off'
Default: 'on'
Parameter: MaxDataPoints
Type: string
Value: any valid value
Default: '1000'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Decimation

Specify that Simulink software output only every N points, where N is the specified decimation factor.

Settings

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.

Tips

  • 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.

Command-Line Information

Parameter: Decimation
Type: string
Value: any valid value
Default: '1'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Save complete SimState in final state

At the end of a simulation, Simulink saves the complete set of states of the model, including logged states, to the specified MATLAB variable.

Settings

Default: Off, xFinal

On

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 StatesImporting and Exporting States for more information.

Off

Simulink software exports the final logged states during simulation.

Tips

  • 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.

Dependencies

This parameter is enabled by Final states.

Command-Line Information

Parameter: SaveCompleteFinalSimState
Type: string
Value: 'on' | 'off'
Default: 'off'
Parameter: FinalStateName
Type: string
Value: any valid value
Default: 'xFinal'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Signal logging

Globally enable or disable signal logging for this model.

Settings

Default: On, logsout

On

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. For more information, see Specify a Name for the Signal Logging Data for a Model.

Off

Disables signal logging to the MATLAB workspace during simulation.

Tips

  • You must select the Signal logging check box before entering the signal logging variable.

  • Simulink saves the signal data in a MATLAB workspace variable having the specified name.

  • The saved data has the format that you specify with the Signal logging format parameter.

  • Simulink 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

  • If you select Signal logging, you can use the Configure Signals to Log button to open the Signal Logging Selector. You can use the Signal Logging Selector to:

    • Review all signals in a model hierarchy that are configured for logging

    • Override signal logging settings for specific signals

    • Control signal logging throughout a model reference hierarchy in a more streamlined way than in previous releases

    You can use the Signal Logging Selector with Simulink and Stateflow® signals.

    For details about the Signal Logging Selector, see Use Signal Logging Selector to View Signal Logging Configuration and Override Signal Logging Settings.

Dependencies

This parameter enables:

  • Signal logging format

  • The Configure Signals to Log button

Command-Line Information

Parameter: SignalLogging
Type: string
Value: 'on' | 'off'
Default: 'on'
Parameter: SignalLoggingName
Type: string
Value: any valid value
Default: 'logsout'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation or during development
Off for production code generation

See Also

Signal logging format

Specify format for signal logging data for this model.

Settings

Default: Dataset

Dataset

Simulink uses a Simulink.SimulationData.Dataset object to store the logged signal data and MATLAB timeseries objects for formatting the data.

ModelDataLogs

Simulink uses a Simulink.ModelDataLogs object to store the logged signal data. Simulink.Timeseries and Simulink.TsArray objects provide the format for the data.

This setting is supported for backward compatibility. Prior to R2012b, the default signal logging format was ModelDataLogs. The ModelDataLogs format will be removed in a future release. For an existing model that uses the ModelDataLogs format, you should migrate the model to use Dataset format. For details, see Migrate from ModelDataLogs to Dataset Format.

Tips

  • You must select Signal logging before specifying the signal logging format.

  • The Dataset format:

    • Uses MATLAB timeseries objects to store logged data (rather than Simulink.Timeseries and Simulink.TsArray objects). MATLAB timeseries objects allow you to work with logging data in MATLAB without a Simulink license.

    • Supports logging multiple data values for a given time step, which can be important for Iterator subsystem and Stateflow signal logging

    • Provides an easy to analyze format for logged signal data for models with deep hierarchies, bus signals, and signals with duplicate or invalid names

    • Avoids the limitations of the ModelDataLogs format. For example, for a virtual bus, logging only logs one of multiple signals that share the same source block. See Bug Report 495436 for a description of the ModelDataLogs limitations.

  • Simulink checks signal logging data format consistency for certain model referencing configurations. For details, see Model Reference Signal Logging Format Consistency. You can use the Upgrade Advisor (with the upgradeadvisor function) to upgrade a model to use Dataset format.

  • An alternative approach for handling reported inconsistencies is to use the Simulink.SimulationData.updateDatasetFormatLogging function to update the models to use Dataset format. This approach sets the Model Configuration Parameters > Data Import/Export > Signal logging format parameter to Dataset for each referenced model and each variant.

  • If you have logged signal data in the ModelDataLogs format, you can use the Simulink.ModelDataLogs.convertToDataset function to convert the ModelDataLogs data to Dataset format.

  • Dataset format is required to log array of buses data.

Simulink uses the Simulink.SimulationData.Dataset data format for logging data stores.

For additional information about specifying the signal logging format, see Specify the Signal Logging Data Format.

Command-Line Information

Parameter: SignalLoggingSaveFormat
Type: string
Value: 'Dataset' | 'ModelDataLogs'
Default: 'Dataset'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Data stores

Globally enable or disable logging of Data Store Memory block variables for this model.

Settings

Default: On, dsmsout

On

Enables data store logging to the MATLAB workspace during simulation.

Specify the name of the data store logging object to use for recording logged data store data. The data store logging object must be in the MATLAB workspace.

Off

Disables data store logging to the MATLAB workspace during simulation.

Tips

Dependencies.  Select the Data stores check box before entering the data store logging variable.

Command-Line Information

Parameter: DSMLogging
Type: string
Value: 'on' | 'off'
Default: 'on'
Parameter: DSMLoggingName
Type: string
Value: any valid value
Default: 'dsmOut'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Output options

Select options for generating additional output signal data for variable-step solvers.

Settings

Default: Refine output

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 Refine Output.

Produce additional output

Generates additional output at specified times. Use Output times to specify the simulation times at which Simulink software generates additional output.

Produce specified output only

Use Output times to specify the simulation times at which Simulink generates output, in addition to the simulation start and stop times.

Tips

  • 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 Samples to Export for Variable-Step Solvers.

Dependencies

This parameter is enabled only if the model specifies a variable-step solver (see Solver TypeSolver Type).

Selecting Refine output enables the Refine factor parameter.

Selecting Produce additional output or Produce specified output only enables the Output times parameter.

Command-Line Information

Parameter: OutputOption
Type: string
Value: 'RefineOutputTimes' | 'AdditionalOutputTimes' | 'SpecifiedOutputTimes'
Default: 'RefineOutputTimes'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Refine factor

Specify how many points to generate between time steps to refine the output.

Settings

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.

Tip

Simulink software ignores this option for discrete models. This is because the value of data between time steps is undefined for discrete models.

Dependency

This parameter is enabled only if you select Refine output as the value of Output options.

Command-Line Information

Parameter: Refine
Type: string
Value: any valid value
Default: '1'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Output times

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.

Settings

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, for the default value [], Simulink generates no additional data points.

  • If the value of Output options is Produce specified output only, for the default value [] Simulink generates no data points.

Tips

  • The Produce additional output option generates output at the specified times, as well as at the regular simulation steps.

  • The Produce specified output only option generates output 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 displays a warning at the MATLAB command line.

  • For additional information on how Simulink software calculates outputs for the Output options Produce specified output only and Produce additional output options, see Samples to Export for Variable-Step Solvers.

Dependency

This parameter is enabled only if the value of Output options is Produce additional output or Produce specified output only.

Command-Line Information

Parameter: OutputTimes
Type: string
Value: any valid value
Default: '[]'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Save simulation output as single object

Enable the single-output format of the sim command.

Settings

Default: off

  • Turning this option 'on' causes Simulink to return all simulation outputs within a single Simulink.SimulationOutput object, providing that you simulate by choosing Simulation > Start from the model window.

  • When turning this option ‘on', you must specify the variable name of the single output object which will contain the simulation outputs. Use the text field next to the check box to specify this name.

  • Enabling this option makes the sim command compatible with the parfor command, in terms of transparency issues.

Tips

  • If you select this option and you simulate by entering the sim command at the command line of the MATLAB command window, then the output variables will not be stored in the object 'out'. Instead, they will be stored in their respective variable names. This design is necessary to avoid workspace issues when sim is called from within a parfor loop.

  • The method who of the Simulink.SimulationOutput object returns the list of variables that the object contains.

  • Use the get method of the Simulink.SimulationOutput object to access the variables that the object contains.

Command-Line Information

Parameter: ReturnWorkspaceOutputs
Type: string
Value: 'on' | 'off' |
Default: 'off'

Parameter: ReturnWorkspaceOutputsName
Type: string
Value: Any valid value
Default: 'Out'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

See Also

Record and inspect simulation output

Specify whether Simulink software records logged signals during simulation.

Settings

Default: Off

On

Simulink records logged signals during simulation. In the Simulink Editor toolbar, this setting turns the Record button on. After Simulink records a simulation, a notification bar appears in the Simulink Editor. In the notification bar, click the link to open the Simulation Data Inspector. The simulation data automatically appears in the Signal Browser table.

Off

Simulink does not record logged signals during simulation. In the Simulink Editor toolbar, this setting turns the Record button off.

Tip

To open the Simulation Data Inspector, in the Simulink Editor toolbar, click the Record button arrow and select Simulation Data Inspector.

Command-Line Information

Parameter: InspectSignalLogs
Type: string
Value: 'on' | 'off'
Default: 'off'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact for simulation and during development
Off for production code generation

See Also

Was this topic helpful?