Main Content

sltest.testsequence.activateScenario

Set Test Sequence block scenario as active

Description

example

sltest.testsequence.activateScenario(blockPath,scenarioName) makes the scenarioName scenario in the specified Test Sequence block active so it runs during simulation. Only one scenario is active at a time. You can use activateScenario only if sltest.testsequence.setScenarioControlSource is sltest.testsequence.ScenarioControlSource.Block, which sets the active scenario control to a Test Sequence block instead of a variable in the workspace. Use sltest.testsequence.getScenarioControlSource to view the current scenario control source setting and sltest.testsequence.setScenarioControlSource to change it.

Examples

collapse all

Set the Test Sequence block in the sltestRollRefTestExample model to use scenarios. Then, add another scenario named Scenario_2 and activate Scenario_2 so it runs when the model simulates. The control source is the default, sltest.testsequence.ScenarioControlSource.Block. Close the model without saving it.

Model = 'sltestRollRefTestExample';
load_system(Model);

sltest.testsequence.useScenario...
   ('sltestRollRefTestExample/Test Sequence',...
   'Scenario_1');

sltest.testsequence.addScenario...
   ('sltestRollRefTestExample/Test Sequence',...
   'Scenario_2');

sltest.testsequence.activateScenario...
   ('sltestRollRefTestExample/Test Sequence',...
   'Scenario_2');

close_system(Model,0)

Input Arguments

collapse all

Path to a Test Sequence block, including the block name, specified as a string or character vector.

Example: 'FanSpeedTestHarness/Test Sequence'

Name of the scenario, specified as a string or character vector.

Example: 'Name','Scenario_1'

Introduced in R2020b