Simulink Test Parameter Override with structs
20 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Jaynik
on 26 Dec 2023
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 Comments
More Answers (0)
See Also
Categories
Find more on Inputs 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!