SimulinkTest 'setVariable' command for a variable located inside a Structure
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Akshat Dalal
2023-11-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Reporting and Database Access 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!