This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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 to create 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 Converting Harness-Driven Models to Use Harness-Free External Inputs

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

From File, From Spreadsheet, and From Workspace blocks work well for this goal.

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

Signal values that source blocks generate 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 big 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.

For array data in a Version 7.0 MAT-file, the From File block loads only double signal values. Use Version 7.3 MAT-files for other types of signal data.

Structure with time

All.

Structure without time

All.

MATLAB® timeseries

All.

Simulink.SimulationData.Dataset

All.

Enumeration

All.

Fixed-point

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 bus data. However, for some kinds of bus data, you need to use a specific technique.

Type of Bus or Bus ElementSupported Techniques

Virtual and nonvirtual buses

All techniques support both types of buses.

The Signal Editor block supports only non-virtual buses.

Root-level input ports and the Signal Editor block do not support loading bus data in rapid accelerator mode.

Partial bus specification

From File and Signal Editor use ground values for unspecified bus elements.

Array of buses signals

Root-level input ports.

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.

Tip

For Excel and CSV spreadsheet requirements, see Storage Formats.

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 logging technique that you choose.

Data Loading HandlingSupported Techniques

Incremental data loading

From File and From Spreadsheet blocks.

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, with these limitations:

  • Root-level input ports only support array and structure data formats.

  • The From Workspace block does not support timeseries format.

  • The Signal Editor block does not support buses in this mode.

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 load ground values in external mode.

Related Examples

More About