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.
- 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.
- 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);
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 Store Data in Dictionary Programmatically
Hope this helps!