Embedded Coder: How can I configure a Simulink model to generate model parameters as regular (non-static) C++ class members?

조회 수: 19 (최근 30일)
Using Embedded Coder, I would like to generate C++ code from my Simulink model and then use multiple instances of the C++ class in my custom C++ code.
How can I prevent model parameters from being generated with the static keyword, so that multiple instances of the generated model class can be used?
I tried different Model settings, StorageClasses and Code Mapping, but the code for the model parameters is always generated as "static":
// Tunable parameters
static P_signalGen_T signalGen_P;

채택된 답변

Pramil
Pramil 2025년 7월 29일
Hi Wojciech,
You can follow the instructions mentioned in the following MATLAB answer to make the model parameters "non-static":
Hope this helps!
  댓글 수: 1
Wojciech Przystas
Wojciech Przystas 2025년 8월 22일 9:57
Hi,
I tried the solution you recommended, and it worked for me - thank you!
However, I find the current setting a bit unintuitive from a user experience perspective.
I’d like to suggest an improvement: it would be helpful to allow users to define the parameter scope directly within the Code Mappings dialog. Since this is where users configure the structure of the generated C++ code, adding a "Scope" column - where one could choose between 'static' and 'local' - would make the configuration more transparent and user-friendly.
Thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by