How can I make block parameters appear as class members of the generated C++ class?

8 vues (au cours des 30 derniers jours)
I have a model which uses variables defined in the workspace. I am generating C++ Class code from this model. I would like the workspace variables to appear as class data members inside the C++ class, that also can be tuned.
What storage class or settings do I need to achieve this?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 26 Juil 2023
Modifié(e) : MathWorks Support Team le 26 Juil 2023
The options depend on whether you need instance-specific or shared parameters.

Shared between instances of the class

If you are okay with the parameter values being the same for all instances of the class, then you have 2 options:
  1. Store the parameter in the Base Workspace or a Data Dictionary and set the storage class to Model Default. This option only works if you have no referenced models.
  2. Store the parameter in the Model Workspace and set the Default Parameter Behavior to Tunable. You don't necessarily need a Simulink.Parameter for this option, because all parameters will be tunable in the code and will show up in the model class

Instance-specific parameters

Plus de réponses (0)

Catégories

En savoir plus sur Code Interface Definitions dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by