To easily exchange scenarios within models, use the Signal Editor block. This block displays, creates, edits, and switches scenarios, where scenarios contain information about groups of signals, such as:
Location of signal files (MAT-file or Microsoft® Excel® files)
Location of the associated model
Use scenarios to exchange groups of signals in your model, such as when running multiple simulations or working with test harnesses.
The Signal Editor displays, creates, and edits interchangeable scenarios and is better integrated with other Simulink® capabilities such as units, signals in MAT-files, and signal edit and creation. Consider using the Signal Editor block in models where you use the Signal Builder block. The Signal Builder block is not recommended to work with signal groups. For more information on benefits of the Signal Editor block, see Replace Signal Builder Block with Signal Editor Block.
The Signal Editor block gets groups of signals (scenarios) from MAT-files.
The block has three sections.
Scenario — Set up a scenario by specifying the MAT-file containing the list of scenarios and selecting the active (current) scenario.
Signal properties — Use the Signal Editor user interface to examine, create, and edit scenarios and associated signals. The Signal Editor user interface organizes the signals according to the scenarios that contain them.
Parameters — Select the active signal to be output and set up characteristics, such as unit, sample time, linear interpolation, and so forth, for the active signal. To change the active signal, use the drop-down list.
This example shows how to use the Signal Editor block with the Parallel Simulations Using Parsim: Parameter Sweep in Normal Mode example, which
runs multiple simulations of a Monte Carlo study in parallel using Parallel Computing Toolbox™. Parallel execution leverages the multiple cores of your host machine to
run many simulations more quickly. If you do not have Parallel Computing Toolbox, this example runs the simulations in serial. The model simulates vehicle
dynamics based on the interaction between road and suspension for different road
profiles. This example stores its road profile scenarios in the
sldemo_suspn_3dof model, open the Signal
Editor (named Road Profiles) block.
The Signal Editor block File Name
parameter contains the MAT-file
Active scenario automatically sets to the first
Road1. This setting means that the
remainder of the block parameters apply to the signals in that scenario.
To change the active scenario, select a new scenario from the list of
Active signal automatically sets to the first
Left tire in the active scenario,
Road1. This setting means that the
remainder of the settings in the Parameter section
apply to the active signal. To change the active signal, select a new
signal from the list of signals.
Explore and edit the scenarios in the MAT-file. Click .
The Signal Editor user interface displays a list of scenarios contained in the MAT-file. Explore and change the scenarios and associated signals. If you make changes, you can save them back to the MAT-file by clicking Save.
The output from the block is the active signal data. To simulate the model
sequentially using each scenario and signal, use the
parsim function. This function simulates dynamic systems multiple times
in parallel or serial. For an example on how to use
Parallel Simulations Using Parsim: Parameter Sweep in Normal Mode.
The Signal Editor provides similar functionality to the Signal Builder block, but with greater flexibility. Replace the Signal Builder with the Signal Editor block. The benefits of Signal Editor block include:
Signal data storage in a MAT-file outside the model
Signal editing and creation
Support for Simulink signal attributes, such as dimension and complexity
Support for standard Simulink data types, including bus and fixed-point
Unique signal-level data types for outputs
Multiple rates for outputs
Support for Simulink units
Zero crossing detection and data interpolation unique to each signal
To port signal data and properties from the Signal Builder block to
Signal Editor block, use the
signalBuilderToSignalEditor function. For the current model,
this function stores to a MAT-file the signal data and properties from an existing
Signal Builder block, adds a Signal Editor block to
the current model, and modifies the Signal Editor block to reference the
For an example see Replace Signal Builder Block with Signal Editor Block.
Converting from the Signal Builder block to the Signal
Editor block is relatively straightforward using the
signalBuilderToSignalEditor function. However, take into
account these considerations:
Internal storage format and preprocessing of data differs between the Signal Builder and Signal Editor blocks. When using the variable step solver, different simulation time steps and mismatched output occur in the two blocks. To minimize the difference between the outputs of both blocks, you can:
Reduce the value of Max step size of the variable step solver.
Insert more data points in the input signal of the Signal Editor block to better represent its shape.
Use the fixed-step solver or set the sample time for both blocks to the same discrete sample time (greater than 0). For more information on discrete sample times, see Discrete Sample Time.
The Signal Builder block supports only doubles. To change the data type or otherwise change the signals after conversion, click the button in the Signal Editor block to access the Signal Editor user interface.
To programmatically get the total number of scenarios and signals in the Signal
Editor block, use the
The values of these properties are character vectors. To convert these values to
doubles, use the
read-only properties available only through
get_param. The block
dialog box does not provide these values.