How to pass a data dictionary parameters as an argument in a model reference?

11 views (last 30 days)
Hello!
I have a model with four instances of a model reference, each instance store its parameters in a data dictionary.
I want to pass different values to those parameters in each instance, but I cannot set those parameters as an arguments.
How is it possible to set a data dictionary parameters as an argument?

Answers (1)

Fangjun Jiang
Fangjun Jiang on 11 Mar 2021
I don't think there is a direct way to do this currently in R2020a. I suggest you try a workaround.
Specify an argument, which is the name of the data dictionary file, for the model reference. In the PreLoadFcn callback of the model, load the specified data dictionary.
  4 Comments
Jonathan Helderen
Jonathan Helderen on 15 Mar 2021
Hi Fangjun Jiang, I tried your suggestion but without any luck.
I get an error that is caused by: Unrecognized function or variable 'DataDictFileName'.
And there is another error: Invalid setting in 'RefLevel/Model' for parameter 'DataDictFileName'.
Fangjun Jiang
Fangjun Jiang on 16 Mar 2021
The variables in model workspace can be referenced by name directly in the Simulink model. To access it through script in MATLAB, you need to use API.
In the PostLoadFcn call back, do this
hws = get_param(bdroot, 'modelworkspace')
hws.getVariable('DataDictFileName')

Sign in to comment.

Categories

Find more on Manage Design Data in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!