Override Model Parameters in a Test Case
Compare simulation to baseline data using a parameter override and the Test Manager.
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.
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
1. Expand the test suite in the Test Browser pane and select the Test Override
test case.
2. Scroll down to the Baseline Criteria section and click Capture.
3. Save the baseline file to writable folder.
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
.
6. Click OK.
7. The test case displays a
in the overrides table. Double-click the Override Value and enter 1.1
.
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 Parameters using Data Files
1. Return to the test case and scroll to the Parameter Overrides section.
2. Click the Add arrow and select Add File
from drop down.
Select the sltestOverrideExampleData.mat
file from the matlab\examples\simulinktest
folder. This file contains data that can be used by the test case to override the parameters.
Select a row, right-click, and select Export. Exports the variable to the MATLAB® base workspace with a variable name a
.
Run the test again and review the results.
sltest.testmanager.clearResults; close(tf); sltest.testmanager.close