How to implement Macro function in simulink.

11 ビュー (過去 30 日間)
Sai Neelam
Sai Neelam 2018 年 7 月 8 日
コメント済み: Sherman 2023 年 3 月 21 日
Hi All,
How can we implement Macro function in simulink.
ex: #define MAX(a,b) (((a)>(b))?(a):(b))
Note: Matlab version: 2018a, Embedded coder for code generation. Regards, sai

回答 (1 件)

Robert
Robert 2018 年 7 月 12 日
You might define a custom header file on the "Simulation Target" tab of your model's parameters. Place a respective file in the directory of that model. I haven't tried with macros yet, but if you declare a function in that header and also provide a custom source file implementing that function, you'll be able to use it in your C-type Stateflow chart. Don't forget to place the same settings at "Code Generation" -> "Custom Code" if you intend to generate code from that model.
  1 件のコメント
Sherman
Sherman 2023 年 3 月 21 日
Depending on what you are trying to do, you could also use Define or ImportedDefine storage classes.

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

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by