Simulink Test Parameter Override with structs

19 visualizaciones (últimos 30 días)
Jake Gareau
Jake Gareau el 20 de Dic. de 2023
Respondida: Jaynik el 26 de Dic. de 2023
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.

Respuesta aceptada

Jaynik
Jaynik el 26 de Dic. de 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!

Más respuestas (0)

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by