Simulink Test Parameter Override with structs
19 次查看(过去 30 天)
显示 更早的评论
I would like to use the paramter Override functionality in Simulink test to modify specific elements of a structure that resides in a datadictionary.
I am able to add the structure to the parameter set in the same way I would add any other parameter but I dont see how I can modify its elements in anyway.
0 个评论
采纳的回答
Jaynik
2023-12-26
Hi Jake,
I understand that you want to modify values of specific elements of a structure that is stored in a data dictionary.
Direct modification is not possible, as the properties of the 'inputParser' class are read-only. Instead, you will need to create a copy of the structure, make the necessary edits, and then assign the new structure back to the parameter set.
Assuming that "p" is a "inputParser" object and "myParam" is the parameter name, you can do the following to change the value of the structure element:
parsedStruct = p.Results.myParam;
parsedStruct.structElement = true;
parse(p,'myParam',parsedStruct);
To modify elements of a "ParameterOverride" object, I assume that you have created a "ParameterSet". You can do the following to change the value of a structure element:
paramSet = testCase.getParameterSets; % testCase is the Simulink Test test case
x = paramSet.addParameterOverride('structVar', myStruct); % myStruct is the structure obtained from the sldd file
x.Value.myStructElement = value; % x.Value will return the structure myStruct
However, this method will not alter the value in the "sldd" file itself. Providing a definitive answer is challenging without a clear understanding of your specific workflow.
Refer to the following link to learn more about "addParameterOverride":
Hope this helps!
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Inputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!