Main Content

Load Data with Interchangeable Scenarios

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

  • Map mode

  • Mapping options

  • Mapped state

Use scenarios to exchange groups of signals in your model, such as when running multiple simulations or working with test harnesses.

Tip

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.

Load Data with Interchangeable Scenarios Using 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.

Explore the Signal Editor Block

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_sigData.mat file.

  1. 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 sldemo_suspn_3dof_sigData.mat.

    Observe that:

    • Active scenario automatically sets to the first scenario, 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 scenarios.

    • Active signal automatically sets to the first signal 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.

  2. 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 parsim, see Parallel Simulations Using Parsim: Parameter Sweep in Normal Mode.

Get Number of Scenarios and Signals

To programmatically get the total number of scenarios and signals in the Signal Editor block, use the get_param NumberOfScenarios and NumberOfSignals properties. The values of these properties are character vectors. To convert these values to doubles, use the str2double function.

NumberOfScenarios and NumberOfSignals are read-only properties available only through get_param. The block dialog box does not provide these values.

See Also

|

Related Topics