Main Content

Comparison of Signal Loading Techniques

Techniques

Simulink® provides several techniques for importing signal data into a model. Each signal data loading technique uses a block to represent signal data sources visually. You can use a:

  • Source block, such as the Sine Wave block, to generate signal data as input to another block

  • Root-level input port (Inport, Enable, or Trigger block). Loading signal data to root-level input ports, either manually or by using the Root Inport Mapper tool. “Root-level input ports” refers to both approaches and “Root Inport Mapper tool” refers specifically to using that tool.

  • From File block

  • From Spreadsheet block

  • From Workspace block

  • Signal Editor block

Impact of Loading Techniques on Block Diagrams

To test reusable systems, it is helpful to separate signal data loading from the block diagram. Loading root-level input ports provides a good framework for testing complex systems on an ongoing basis. Using the Root Inport Mapper tool allows you to visualize the signal data that is loaded.

To perform temporary testing on standalone models, adding data loading blocks can be simpler and make the source of the signal data visible from within the block diagram.

To avoid adding data loading blocks to a model, load the signal data to root-level input ports. You can change the data to use by changing the Configuration Parameters > Data Import/Export > Input parameter. You do not need to add or change blocks, or reset block parameters. You can use the Root Inport Mapper tool to update the Input parameter so that it reflects the mapping of signal data to the appropriate ports.

Test Harness Models

You can use a test harness model with different test cases to load:

  • Different signal data to a port

  • Signal data to different ports

The Signal Editor block is useful in test harness models to simplify loading data to multiple input ports.

Alternatively, you can use the Root Inport Mapper tool to create scenarios that you can use instead of creating separate test harness models. Creating separate test harness models can be simpler than setting up root inport mapping. However, you then need to manage the separate test harness models. For an example of using root inport mapping instead of a test harness, see Create Harness-Free Models with MAT File Input Data.

Comparison of Techniques

Each technique addresses many of these modeling considerations:

Purpose of Importing Signal Data

The model development phase you are in and your goals for loading signal data can influence the signal loading technique that you choose.

Modeling GoalSupported Techniques

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

All

Root-level input ports for reusable systems.

Test a model that you want to use as a referenced model

Root-level input ports.

Verify a model by using multiple test cases

Root Inport Mapper tool, using exported signal data.

Signal Editor block.

Represent a continuous plant

All

Root-level input ports work well for this goal.

Test a discrete algorithm

All

Root-level input ports work well for this goal.

Model Development Phase

Modeling RequirementSuggested Signal Loading Technique

Initial prototyping

When signals generated by source blocks meet your requirements, use Source blocks.

From File, From Spreadsheet, and From Workspace blocks.

System testing, sharing, and code generation

Root-level input port.

You can use the Root Inport Mapper tool to create and map signal data to load

Signal Editor block

For many models, loading signal data to a root Inport block is an effective approach. The Root Inport Mapping tool provides a convenient way to load data for several signals to root inports.

Signal Data

The amount, source, and kind of the signal data can influence the signal loading technique that you choose.

Signal DataSupported Techniques

Large data set

From File and From Spreadsheet blocks work well for large data sets, because they incrementally load the data.

You can log simulation data to persistent storage and then incrementally load data from a file to root-level Inport blocks.

Data exported by using a To File block

From File block.

Data exported by using a To Workspace block

From Workspace block.

Excel® or CSV spreadsheet

From Spreadsheet block, which can import Microsoft® Excel (all platforms) or CSV (Microsoft Windows® platform with Microsoft Office only) spreadsheet data directly into Simulink.

Variable-size signals

From Workspace block.

Data Format or Type

Each of the signal loading techniques supports a wide range of data formats for signal data (such as array or Dataset). A few signal loading techniques have some limitations for specific formats.

Note

Some of the Root Inport Mapper tool map modes do not support all the data types that you can use with the tool. For details, see Choose a Base Workspace and MAT-File Format.

Data Format or TypeSupported Techniques

Array

All.

Structure with time

Root-level Inport block

From Workspace block

Signal Editor block

Structure without time

Root-level Inport block

From Workspace block

Signal Editor block

timeseries

All.

timetable

Root-level Inport block

From Workspace block

Signal Editor block

Simulink.SimulationData.Dataset

Root-level Inport blocks

Signal Editor block

Enumeration

All.

Fixed-point

From Workspace block supports loading fi objects created using Fixed-Point Designer™.

From File block has a word length limit of 32 or fewer bits.

Function-call

Root-level input ports (select the Output function call parameter).

Bus Support

You can use any of the signal loading techniques to load input data for a bus. However, for some kinds of bus data, you need to use a specific technique.

Type of Bus or Bus ElementSupported Techniques

Nonvirtual buses

All techniques support loading input data for a nonvirtual bus.

The Signal Editor block does not support loading bus data in rapid accelerator mode.

Partial bus specification

Root-level Inport block

From Workspace block

From File block

Signal Editor block

Array of buses

Root-level Inport block

From Workspace block

Time Points

The kind of time points in signal data impacts the signal loading technique that you choose.

Time Points for Signal DataSupported Techniques

Single time point

All.

Continuous

All.

Discrete

All.

Repeated sequence without time

Structure data by using root-level input ports and From Workspace block.

Location for Data Storage

Whether you want to store the signal data with the model or separate from the model impacts the signal loading technique that you choose.

LocationSupported Techniques

In the base or model workspace

From Workspace block.

Root-level input ports or a Trigger, Enable, or Function-Call Subsystem block.

In a MAT-file separate from the model file

From File and Signal Editor blocks.

You can log big simulation data to persistent storage and then incrementally load data from a file to root-level Inport blocks.

In an Excel or CSV spreadsheet

From Spreadsheet block.

Note

Loading CSV data is supported only for Microsoft Windows platforms.

Signal Data Inspection

The Root Inport Mapper tool, From File block, and Signal Editor block each provide an interface for plotting and inspecting the signal data to load.

Handling of Loaded Data

How Simulink processes the signal data as it loads it into a model impacts the signal loading technique that you choose.

Data Loading HandlingSupported Techniques

Incremental data loading

From File and From Spreadsheet blocks.

Root-level Inport blocks, when you load data from a Simulink.SimulationData.DatasetRef object or matlab.io.datastore.SimulationDatastore object

Interpolation

All.

Extrapolation

From File, From Spreadsheet, and Signal Editor blocks. For information about From Workspace extrapolation, see Form output after final data value by.

Zero-crossing detection

All except root-level input ports.

Fast restart

All techniques.

Simulation Mode

All signal loading techniques support all simulation modes except for SIL or PIL. Some techniques have limitations for specific simulation modes.

Simulation ModesSupported Techniques

Normal and accelerator

All

Rapid accelerator

All

ERT/GRT

All

From Workspace and From File blocks are not tunable.

SIL or PIL

From Workspace block

External mode

From Workspace block

Root-level input ports output ground values in external mode.

Related Topics