Changing function packaging of Simulink Functions to inlined

11 views (last 30 days)
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?

Answers (2)

Fangjun Jiang
Fangjun Jiang on 20 Jul 2020
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 Comment
Monika Jaskolka
Monika Jaskolka on 20 Jul 2020
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.

Sign in to comment.


Jonas
Jonas on 6 May 2021
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.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!