フィルターのクリア

SimulinkTest 'setVariable' command for a variable located inside a Structure

6 ビュー (過去 30 日間)
Adesh Prasad
Adesh Prasad 2022 年 1 月 20 日
回答済み: Akshat Dalal 2023 年 11 月 20 日
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

回答 (1 件)

Akshat Dalal
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.

カテゴリ

Help Center および File ExchangeTest Execution についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by