SimulinkTest 'setVariable' command for a variable located inside a Structure
4 views (last 30 days)
Show older comments
hi.
I have a structure called 'LevGuiEmulatorData.HIL.LeftLev', which is located in the base workspace, and inside this structure I have several variables. I want to change one of the variables (R_nom) as to the value I define in my Scripted Iteration script found in Simulink Test's Test Manager.
If I had R_nominal in the baseworkspace and I define R_defined in my script, the command would look like this:
setVariable(testItr,'Name','R_nominal','Source','base workspace',...
'Value',R_defined)
If I try to change R_nom in the structure by substituting the Name with the full path of the structure, it doesn't work... i.e.
setVariable(testItr,'Name','LevGuiEmulatorData.HIL.LeftLev.R_nom','Source','base workspace',...
'Value',R_defined)
Could I get some help on what is the correct syntax?
Thanks very much.
adesh
0 Comments
Answers (1)
Akshat Dalal
on 20 Nov 2023
Hi Adesh,
I understand that you want to modify the ‘'LevGuiEmulatorData.HIL.LeftLev' structure defined in your ‘base workspace’ using the ‘setVariable’ function.
The syntax you are using is the correct way to modify structures defined in the ‘base workspace’ using the ‘setVariable’ function. If this approach is not working, you could try getting the whole structure using the ‘getVariable’ function, modifying it locally in your script and then assigning the modified structure back to the ‘base workspace’ using the ‘setVariable’ function.
To read more the ‘getVariable’ function, please refer the following documentation: https://www.mathworks.com/help/simulink/slref/simulink.modelworkspace.getvariable.html
To read more the ‘setVariable’ function, please refer the following documentation: https://www.mathworks.com/help/simulink/slref/simulink.simulationinput.setvariable.html
I hope this helps.
0 Comments
See Also
Categories
Find more on Test Execution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!