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.
sltest.testmanager.view
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. Then, click Capture.
4. Expand the Parameter Overrides section in the test case and click Add.
5. In the dialog box, if no parameters are displayed, 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)
under Baseline Criteria Result to see how overriding the parameter affects 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.
Select the sltestOverrideParameter.mat
file. This file contains data that can be used by the test case to override the parameter.
If you want to access the override value in the MATLAB® base workspace, select the row with the override value from the file, right-click, and select Export. The override value is exported to the workspace as a variable named a
.
Run the test again. In the Results and Artifacts pane, expand the new results to see the Baseline Criteria Result. Select Mux: 1(2)
, 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.
sltest.testmanager.clearResults; close(tf); sltest.testmanager.close