Simulink Test Parameter Override with structs

조회 수: 20 (최근 30일)
Jake Gareau
Jake Gareau 2023년 12월 20일
답변: Jaynik 2023년 12월 26일
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.

채택된 답변

Jaynik
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개)

카테고리

Help CenterFile Exchange에서 Inputs에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by