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.

Load Data with Interchangeable Scenarios

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. To easily exchange scenarios within these models, use the Signal Editor block. This block displays, creates, edits, and switches scenarios.

Tip

Consider using Signal Editor block in models where you use the Signal Builder 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 scenario, such as specifying the MAT-file containing the list of scenarios and 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. The

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 matlab\toolbox\ssldemo_suspn_3dof_sigData.mat file.

  1. In the sldemo_suspn_3dof model, open the Signal Editor block.

  2. 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.

  3. Explore and edit the scenarios in the MAT-file. lick .

    The Signal Editor user interface displays with the list of scenarios contained in the MAT-file. Explore and manipulate the scenarios and associated signals. If you make changes, you can save them back to the MAT-file.

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.

Replace Signal Builder Block with Signal Editor Block

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 outside model in MAT-file

  • Signal edit 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 forSimulink 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 new MAT-file.

For an example, see Replace Signal Builder Block with Signal Editor Block.

Considerations

Converting from Signal Builder block to 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 Signal Editor block button to access the Signal Editor user interface.

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. These properties contain the values as character vectors. To convert these values to doubles, use the str2double function.

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

See Also

| |

Related Topics