could the data dictionary be used as kind of struct like variables in workspace ?

2 views (last 30 days)
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
ED
ED on 14 Apr 2025
Hi Adarsh and Daniel:
Both the dd can be used with struct, but when it comes to code generation, the variables are replaced by values other than tunable variables.
So does any method that struct in data dictionary be used in model and are embodied in the code generated?

Sign in to comment.

Answers (1)

Adarsh
Adarsh on 2 May 2025
Hi @ED,
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:
  1. Open “Model Settings” in the “Modeling” tab.
  2. Goto “Code Generation” section and click on “Optimization” under it.
  3. 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!