How can I programmatically override referenced configuration parameters?

조회 수: 6 (최근 30일)
Jonathan Adams
Jonathan Adams 2020년 4월 6일
답변: Rajanya 2024년 10월 3일
I have a reference configuration set applied to a large collection of custom blocks. I am trying to programmatically override certain parameters depending on which block I am working with. From the documentation there is a way to do this within the Configuration Parameters GUI, but is there a way to access the override functionality from within a script when using reference configuration sets?

답변 (1개)

Rajanya
Rajanya 2024년 10월 3일
I understand that you are trying to control the configuration parameters of a reference model programmatically. A configuration reference is especially designed to ensure consistency across multiple models by referencing a shared configuration set. Thus, parameter update is not directly supported for a configuration reference via scripts; but a workaround can be made to achieve similar results.
  1. The configuration set can be changed entirely but doing this will change the configuration parameters for all the models using the reference set, so make sure you actually desire this before taking this approach.
  2. For parameter update to a particular block, the configuration set can be cloned, and the cloned copy can be used to make necessary changes to the model parameters. This cloned copy can then be added to the model. A sample demonstration to achieve the same is shown using the ‘LinearActuator’ and ‘nonLinearActuator’ example Simulink models.
Both the ‘LinearActuator’ and the ‘nonLinearActuator’ are made to reference a common configuration set called ‘sharedConfig’, and then the ‘nonLinearActuator’ model’s ‘System Target File’ is made to change to ‘grt.tlc’ as opposed to the reference set’s ‘System Target File’ of ‘ert.tlc’ which is also inherited by ‘LinearActuator’.
After creating the copy in ‘clonedConfigSet’ and setting the parameters accordingly, the new configuration set is added to model explorer using ‘attachConfigSet’ and is activated using ‘setActiveConfigSet’.
modelName = 'NonLinearActuator';
configRef = getConfigSet(modelName, 'Configuration');
clonedConfigSet = configRef.copy;
set_param(clonedConfigSet, 'SystemTargetFile', 'grt.tlc');
attachConfigSet(modelName, clonedConfigSet, true);
setActiveConfigSet(modelName, clonedConfigSet.Name);
save_system(modelName);
This creates a new copy configuration ‘Configuration2’ which the desired model uses.
You can use the following commands to view the documentations of the used functions for more information.
doc attachConfigSet;
doc setActiveConfigSet;
doc Store Data in Dictionary Programmatically
Hope this helps!

카테고리

Help CenterFile Exchange에서 Multicore Processor Targets에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by