
How do I use "setVariable" when running Real-Time Tests with Scripted Iterations on my Speedgoat target?
17 views (last 30 days)
Show older comments
MathWorks Support Team
on 12 May 2017
Edited: MathWorks Support Team
on 16 Feb 2026 at 21:56
I’m trying to run automated tests on a Speedgoat target using Simulink Test & Simulink Real-Time (SLRT). I created a Real-Time Test Case in Test Manager to run a parameter sweep with Scripted Iterations using the TestIteration object's "setVariable" function.
However, when I attempt to override a base workspace global parameter ‘ParamName’ with:Similarly, when I try to override a block parameter, e.g., the Pulse Generator ‘Amplitude’, with:
setVariable(testIter,'Name','ParamName','Source','base workspace','Value',1);
The test case fails with an "Invalid model parameter setting" error:
Invalid model parameter setting in test iteration
setVariable(testIter,'Name','Amplitude','Source','MyModel/Pulse Generator/Amplitude','Value',1)
The test case fails with an "Invalid parameter" error:
Invalid parameter 'MyModel/Pulse Generator/Amplitude'.
How can I override parameters in my real-time application when using Scripted Iterations?
Accepted Answer
MathWorks Support Team
on 16 Feb 2026 at 0:00
Edited: MathWorks Support Team
on 16 Feb 2026 at 21:56
The errors above occur because the 'Source' argument must be used differently for Real-Time Test Cases, as documented on the "setVariable" help page. Workspace names such as 'base workspace' or 'model workspace' are not valid.
Use the following syntax for Real-Time Tests with Speedgoat:
(1) To override a global parameter, e.g. a Simulink parameter ‘ParamName’ defined in the base or model workspace, you can just use an empty vector for 'Source':
setVariable(testIter,'Name','ParamName','Source','','Value',1);
(2) To override a block parameter, pass the block path as the 'Source' and the parameter as 'Name':
setVariable(testIter,'Name','Amplitude','Source','MyModel/Pulse Generator','Value',1)
Notice that the 'Source' corresponds to the 'Model Element' as shown in the Parameter Overrides table for this use case:

Refer to the "Create Scripted Iterations" section in our Real-Time Testing example for more information:
0 Comments
More Answers (0)
See Also
Categories
Find more on Test Execution in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!