Documentation Center

  • Trial Software
  • Product Updates

Techniques for Importing Signal Data

Signal Data Import Techniques Summary

Simulink® provides several techniques for importing signal data into a model.

Signal Data Import TechniqueDescription

Root-level Inport,Trigger, Enable, or Function-Call Subsystem block

Supplies external inputs from the MATLAB® (base), model, or mask workspace. Specify the external inputs in the Configuration Parameters > Data Import/Export > Input parameter or as a sim command argument.

To import and map signal and bus data to root-level inports at the same time, you can use the Inport Mapping tool. For details, see Import and Map Root-Level Inport Data. Use this method if you have many signals to import and map.

For an example of a more manual way to import signal data and map it to root-level inport, see Import Data to Root-Level Input Ports. Consider this method if you have few signals to import and map.

From File block

Reads data from a MAT-file and outputs the data as a signal.

From Workspace block

Reads data from the MATLAB (base), model, or mask workspace and outputs the data as a signal.

For an example, see Use From Workspace Block to Import an Input Test Case.

Signal Builder block

Provides a graphical interface for creating and generating interchangeable groups of signals.

For examples, see Use Signal Builder Block to Import an Input Test Case and Import Signal Data.

Each of these techniques:

  • Uses blocks to represent the signal data inport sources visually

  • Supports data interpolation and extrapolation, which support the use of incomplete sets of signal data

  • Supports zero-crossing detection

Comparison of Techniques

Each technique is well-suited to meet one or more of the following modeling considerations.

Modeling ConsiderationSuggested Technique

Purpose of importing signal data

To perform local, temporary testing by importing a small set of signal data

  • From File block

  • From Workspace block

  • Signal Builder block

  • Root-level Inport, Trigger, Enable, or Function-Call Subsystem block

To test a model to be used as a referenced model

Root-level Inport, Trigger, Enable, or Function-Call Subsystem block

To verify a model using multiple test cases

Signal Builder block, using signal groups.

If the Simulink Verification and Validation™ software is installed, in signal groups you can use the Verification Manager to enable or disable individual Model Verification blocks. For details, see Model Verification Blocks and the Verification Manager.

To perform local, temporary testing by importing a small set of signal data

Depending on the modeling goal, as discussed in Time and Signal Values for Imported Data, choose from the following techniques:

  • From File block

  • From Workspace block

  • Signal Builder block

  • Root-level Inport, Trigger, Enable, or Function-Call Subsystem block

Signal data

Very large dataset

From File block, which incrementally loads the data

Data exported using a To File block

From File block

Data exported using a To Workspace block

From Workspace block

Excel® spreadsheet

Signal Builder block, which can import Excel spreadsheet data directly into Simulink

Variable-size signals

From Workspace block

Array of buses signals

root Inport block

Data storage

In a block

Signal Builder block

In the base or model workspace

  • From Workspace block

  • Root-level Inport, Trigger, Enable, or Function-Call Subsystem block

In a MAT-file separate from the model file

From File block

Time and Signal Values for Imported Data

Depending on your model development or testing goal, the approach for specifying time and signal values can vary. Each of these guidelines applies to one or more of the signal data import techniques (From File, From Workspace, Signal Builder, and root-level Inport or Trigger blocks).

Modeling GoalTime and Signal ValuesAdditional Notes

Import data representing a continuous plant

Specify a time vector and signal values extracted a continuous plant (for example, data that you acquire experimentally or from the results of a previous simulation).

Use any of the data formats listed in Input Data. Here are recommended formats for the following imported data sources:

  • Another simulation — Dataset

  • An equation — MATLAB time expression

  • Experimental data — MATLAB timeseries, data array, or structure

For details, see Specify Time Data. For an example of using a structure to specify the time and signal values, see Import Data to Model a Continuous Plant.

In the Inport block parameters dialog box, select Interpolate data.

To ensure that the Simulink variable time solver executes at the times that you specify in the imported data, set the Configuration Parameters >
Data Import/Export
>
Output options
parameter to Produce additional output.

Test a discrete algorithm

Use a structure, with an empty time vector.

Specify signal values, but no time vector. (One signal value is read at each time step, using the sample time of the source block.)

For an example of using a structure to specify the signal values, see Import Data to Test a Discrete Algorithm.

In the Inport block parameters dialog box, clear Interpolate data.

Create an input test case

(An input test case is typically composed of steps and ramps, with discontinuities.)

Specify a time vector and signal values, but specify only the time steps at points where the shape of the output jumps.

For details about specifying a time vector, see Specify Time Data.

Use any of the input data formats described in Input Data, except for MATLAB time expressions.

Select the Interpolate data parameter.

For the input, consider using a From Workspace, From File, or Signal Builder block, which trigger a zero-crossing at the discontinuities.

For examples of using a From Workspace block and a Signal Builder block, see Import Data for an Input Test Case.

Was this topic helpful?