Simulink AUTOSAR Blockset - macro for PI

5 ビュー (過去 30 日間)
Nicolas B
Nicolas B 2025 年 2 月 21 日
コメント済み: Nicolas B 2025 年 4 月 23 日
Hi,
I am generating code from Simulink using AUTOSAR blockset and I would like to avoid having pi as magic number in my code. However, because it is not really a parameter, I would like to try to get Simulink coder to define a macro that sets pi value (e.g. M_PI).
Unfortunately, I haven't found how to do that. Anyone as an idea?
Regards, Nicolas

採用された回答

SACHIN KHANDELWAL
SACHIN KHANDELWAL 2025 年 4 月 22 日
Assuming that you want to define the value of pi as macros (M_PI), here are some steps that you can follow and achieve the same.
  1. Use the Define storage class: This allows you to generate #define statements in your code. For more information, see: https://www.mathworks.com/help/ecoder/ug/macro-definitions-define.html
  2. Use the Custom Code in Simulink Coder: You can declare macros as custom code using Custom Code settings. Learn more here: https://www.mathworks.com/help/simulink/ug/specify-configure-custom-c-code.html
I trust that this resolves the issue. If not , please share reproduction steps with dummy model data.
  1 件のコメント
Nicolas B
Nicolas B 2025 年 4 月 23 日
Thank you Sachin, very helpful.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAUTOSAR Blockset についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by