Main Content

Capture Simulation Data in a Test Case

Capture signal data in your test results by adding signals to the Simulation Outputs section of the test case. Each output is called a logged signal. Signals listed in Simulation Outputs appear in the test results along with signals that are already selected for logging in Simulink®.

You can use logged signals for data comparison in baseline criteria, equivalence criteria, custom criteria, and for data visualization in the Simulation Data Inspector. Logged signals enable you to further test your Simulink model without changing the model. In addition to signals from the top model, you can also log signals from subsystems and model references. You can select signals associated with local and global data store memory, and from data store memory that uses a Simulink.Signal object.

Add Logged Signals in the Test Manager

To add signals:

  1. Open the model sltestFlutterSuppressionSystemExample.

  2. Use sltestmgr to open the Test Manager.

  3. In the Test Manager, under Simulation Outputs, click Add.

  4. In the system under test, highlight blocks or signals that you want to log. To select multiple items, click and drag a selection box over multiple items.

  5. A dialog box appears. Select signals in the dialog box.

  6. Continue adding signals to the test case. Each time you select a signal, the dialog box also shows previously logged signals. You can remove a signal from logging by clearing the selection.

  7. When you finish adding signals, return to the Test Manager and click Done.

  8. The signals appear in the Logged Signals table in the test case.

To add a signal set, click the Add arrow and select Signal Set.

To specify a specific plot for a signal, enter a number in the Plot Index column. By default, the signals appear on one plot.

You can specify to display the plot immediately after running the test by selecting the Plot signals on the specified plots after simulation check box.

After you run the test, the logged signals appear in the test case results under Sim Output. Select each signal to display on the plot. If you specify a plot index, the signal appears in the plot number you specified.

Capture Data from Local and Global Data Stores

Perform similar steps to add simulation output associated with data store memory:

  1. Open the model sldemo_mdlref_dsm, which contains local and global data store memory.

  2. In a test case, from the top model, add the Sine Wave block for logging.

  3. Click on the Data Store Read block in the top model. Click on the click to update diagram box. The dialog box displays the signal associated with the block and the data associated with the Simulink.Signal object in the base workspace. The model displays the signal storage class for the block, (global).

  4. Select both signals in the dialog box.

  5. Double-click the model reference sldemo_mdlref_dsm_bot to open it, and then open the subsystem PositiveSS. Select the Data Store Write block. The table displays the input signal from the Gain block and the data store memory, RefSignalVal.

  6. Select the RefSignalVal data store memory for logging. The dialog box uses a different icon to indicate the data store memory.

  7. Finish selecting signals by clicking Done in the Test Manager window. In the Test manager, the signals appear under Logged Signals. The Source column displays the full path information for each signal. For the signal associated with the Simulink.Signal object, Source displays the workspace location of the Simulink.Signal object.

Logging Leaf Signals of a Bus

In addition to logging an entire Bus block, you can select one or more individual signals within a bus and add them to the Logged Signals section of Test Manager. For large buses, adding only the needed signals might reduce the amount of time it takes a test case to run.

  1. Open the model, sldemo_absbrake.

  2. Use sltestmgr to open the Test Manager.

  3. Click New > Test File to create a new test file. Name and save the file.

    Under System Under Test, click the Use current model icon.

  4. Under Simulation Outputs, click Add.

  5. In the system under test, select the signal exiting the Bus, yout.

  6. A dialog box appears. Select the desired bus or bus leaf signals in the dialog box. Three horizontal lines indicate the whole bus. A single horizontal line next to a signal name indicates that it is a bus leaf signal. If the leaf signals do not appear in the dialog, click Click to update diagram.

    Bus signal selection dialog

  7. Continue adding signals to the test case, such as the non-bus Sd and tire torque signals

  8. When you finish adding signals, return to the Test Manager and click Done.

  9. The signals appear in the Logged Signals table in the test case.

    Logged signals section of test manager

To add a signal set, click the Add arrow and select Signal Set.

To specify a specific plot for a signal, enter a number in the Plot Index column. By default, the signals appear on one plot.

You can specify to display the plot immediately after running the test by selecting the Plot signals on the specified plots after simulation check box.

See Also

| | | |

Related Topics