Changing function packaging of Simulink Functions to inlined

10 ビュー (過去 30 日間)
Monika Jaskolka
Monika Jaskolka 2020 年 7 月 20 日
回答済み: Jonas 2021 年 5 月 6 日
Why is the Function Packaging option disabled for Simulink Functions? I'd like to edit this parameter to modify how the function is code-generated. I have Embedded Coder installed.
Here is an example of a very simple Simulink Function that does nothing, yet it is still generated as a function. Is it possible to force it to be inlined?

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2020 年 7 月 20 日
Inline would make that block a regular subsystem block, not a Simulink Function. A Simulink Function is called by its name, so I don't think there is any other way.
  1 件のコメント
Monika Jaskolka
Monika Jaskolka 2020 年 7 月 20 日
You can have inlined functions in C, so I think it would make sense to be able to generate inlined functions out of Simulink Functions.

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


Jonas
Jonas 2021 年 5 月 6 日
I have the same question. I want to inline a Simulink Function, but the option is disabled. However, when integrating a Simulink Function locally inside a Stateflow, I can inline the function successfully. Why is it not possible to inline a Simulink Function outside Stateflow charts?
Although I do not know why it is not possible, I have found a work-around for my use-case. Might be interesting for you.
Instead of using a Simulink Function, I have put the contents of the function as a subsystem in my library, checked 'Treat as Atomic unit' and then the option becomes available to force 'inline' for code generation.
If you want to use the block directly in your model, you just use the library block and it will be inlined. If you want to call the function by its name in a Stateflow chart, you use a local Simulink Function in the Stateflow chart and put the library block inside there. You can force inlining for the local Simulink Function in Stateflow.
The only caveat is that it is not possible to call the library block inside a MATLAB Function, because it requires a Simulink Function to do that. But for my application, I don't need it.

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by