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

2 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2023-7-26
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Code Interface Definitions 的更多信息

标签

尚未输入任何标签。

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by