How can I programmatically override referenced configuration parameters?

7 views (last 30 days)
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?

Answers (1)

Rajanya
Rajanya on 3 Oct 2024
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!

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!