make a static const variable in generated code with Embedded Coder

15 ビュー (過去 30 日間)
Marcel Günther
Marcel Günther 2021 年 7 月 6 日
コメント済み: Marcel Günther 2021 年 7 月 6 日
Hello,
I'm using Embbeded Coder to generate code which is included to a superordinated C project.
This superordinated C project need to access some data, defined in matlab.
Since this data need to be accessible to compile-time, it need to be generated by Embedded Coder as:
static const float MyNumber = 42.0f;
How to achieve this?
Thank you very much.

回答 (1 件)

Jonas
Jonas 2021 年 7 月 6 日
In either the Model Workspace or a Data Dictionary linked to your model, create a Simulink.Parameter object and name it "MyNumber". Give it data type 'single' and value 42.0. Go to the Code Generation tab, and select as Storage class 'Const'.
  1 件のコメント
Marcel Günther
Marcel Günther 2021 年 7 月 6 日
This makes the MyNumber appear in the model.c file. But how to add it to the model.h file, to make the constant value visible to the superordinate c-project? Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by