Changing function packaging of Simulink Functions to inlined
18 次查看(过去 30 天)
显示 更早的评论
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/334596/image.png)
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/334602/image.png)
0 个评论
回答(2 个)
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.
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!