Define Inline function for specific subsystem in generated auto code by embedded code in Simulink

조회 수: 8 (최근 30일)
Is it possible to define a inline function in autocode for secific subsystem
Inline void func()
{
}
void model_step()
{
func();
}
I have checked this documention --> https://in.mathworks.com/help/simulink/slref/subsystem.html . But Its not explaining that

답변 (1개)

Epsilon
Epsilon 2025년 5월 15일
Hi Jarvis,
Yes, it is possible to control how code is generated for a specific subsystem in Simulink using Embedded Coder. By default:
  • Virtual subsystems do not generate a separate function in the code; their contents are inlined directly into the parent function.
  • Atomic (nonvirtual) subsystems typically generate a separate function for the subsystem. However, you can configure how this function is generated, and it can be configured to be inlined as well.
To explicitly define an inline function for a specific subsystem:
  1. Right-click the Subsystem block and select Block Parameters (Subsystem).
  2. In the dialog box, ensure "Treat as atomic unit" is checked. This makes the subsystem atomic (nonvirtual) and allows for advanced code generation options.
  3. Go to the Code Generation tab.
  4. Set the Function packaging parameter to Inline.
The documentation for the same can be refered to at: https://www.mathworks.com/help/rtw/ug/inline-subsystem-code-ecoder.html
  댓글 수: 2
Walter Roberson
Walter Roberson 2025년 6월 1일
@jarvis comments
Actually I have tried that option also. But problem even though If you select function packaging as inline the code is inline in actual function in generated code Its not generating like inline custom_func() { } void step() { custom_func(); }
jarvis
jarvis 2025년 6월 2일
yes. MATLAB is not generating code like inline function.
I don't know wheather that feauture is available or not

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by