Main Content

Override Model Parameters in a Test Case

Compare simulation to baseline data using a parameter override.

This example shows how to override a parameter defined in a model workspace using the Test Manager, and view its effect on model output compared to a baseline. Information about using external files to override parameters is also included.

Open the Test File

Open the Test Manager.


Open the test file.

tf = sltest.testmanager.load('sltestParameterOverridesTest.mldatx');

Overriding a Model Parameter by Manually Setting Its Value

1. In the Test Browser pane, select the Test Override test case.

2. Scroll down to the Baseline Criteria section and click Capture.

3. Specify the File to which to save the baseline data. The folder must be writable. Then, click Capture.

4. Expand the Parameter Overrides section in the test case and click Add.

5. In the dialog box, click the Refresh button to display available parameters. Select a, which is the gain in the model.

6. Click OK.

7. The test case displays a in the overrides table. Double-click the Override Value and enter 1.1.

Note that parameter overrides are evaluated when the test runs.

Run the Test and View Results

Select the test file in the Test Browser pane and click Run. In the Results and Artifacts pane, expand the results to see the Baseline Criteria Result and Sim Output.

Select Mux: 1(1) inside Baseline Criteria Result to see how overriding the parameter a affected the mux signal when compared to the captured baseline. The comparison output shows a maximum difference of approximately 0.6.

Overriding a Model Parameter using a MAT-File

1. Return to the Test Browser panel, select the Test Override test case, and expand the Parameter Overrides section.

2. Click the Add arrow and select Add File from drop down.

In your working directory, select the sltestOverrideExampleData.mat file. This file contains data that can be used by the test case to override the parameters.

Select the row with the override value from the file, right-click, and select Export. The variable is exported to the MATLAB® base workspace with variable name a.

Run the test again and review the results, which shows the effect of increasing the value of the mux signal gain (a).

You can also use parameter override data from MATLAB script (.m) and Excel files.


Related Topics