could the data dictionary be used as kind of struct like variables in workspace ?
Show older comments
I just want to use the parameters in data dictionary in the form of struct such as


I tried many methods without success. is there any method to realize this as one with workspace like Param.k1?
10 Comments
Daniel
on 1 Apr 2025
You can use structs in data dictionaries. It's probably easiest to define the struct in the base workspace and then copy paste it to the DD.

ED
on 1 Apr 2025
Daniel
on 1 Apr 2025
Were you able to make it work now? If not, try creating the struct object in the base workspace and within the model explorer copy and paste it into your data dictionary. Alternatively, you can try to add a normal MATLAB variable into your data dictionary and enter "struct" for its value? What version are you using?
ED
on 1 Apr 2025
Daniel
on 1 Apr 2025
This should work in older releases - I have created a small example in R2020a
ED
on 1 Apr 2025
Daniel
on 1 Apr 2025
You should be able to open the model with your R2022a version? Or do you only have 17b/18b available?
After storing the struct in the dictionary have you tried linking the dictionary to the model. If not please follow the below steps to link the dictionary to the Simulink model (Also make sure you have saved the changes in the dictionary):
- Open the Simulink model.
- Open "Modelling Tab".
- From the drop down in "Design" section select "link to data dictionary" option and link the required data dictionary file where the struct is stored.
- Run the model after entering the required parameters.

ED
on 3 Apr 2025
ED
on 14 Apr 2025
Answers (1)
Adarsh
on 2 May 2025
0 votes
I understand that you are trying to use a struct to store the parameters in a Simulink data dictionary and utilizing it for “Code generation” for the Simulink model.
Firstly, link the dictionary to the model using the following steps:
- Open the Simulink model.
- Open "Modelling Tab".
- From the drop down in "Design" section select "link to data dictionary" option and link the required data dictionary file where the struct is stored.
- Run the model after entering the required parameters.
Now, In the Embedded coder, click on “Generate Code” button. Once the code is generated check if the parameters are “inlined” or in “tunable” state. If the parameters are “inlined” then it is due the optimizations enabled while code generation.
You can resolve this by following the below steps:
- Open “Model Settings” in the “Modeling” tab.
- Goto “Code Generation” section and click on “Optimization” under it.
- Change the “Default parameter behavior” option from “Inlined” to “Tunable” and run the code generation once again to use the “struct” instead of “values”.
Hope this helps!
Categories
Find more on Manage Design Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!