| Writing S-Functions | ![]() |
The Inlined Code
The code generated when you inline your wrapper S-function is similar to the default generated code. The mdlTerminate function no longer contains a call to an empty function and the mdlOutputs function now directly calls my_alg.
void mdlOutputs(int_T tid) { /* Sin Block: <Root>/Sin */ rtB.Sin = rtP.Sin.Amplitude * sin(rtP.Sin.Frequency * ssGetT(rtS) + rtP.Sin.Phase); /* S-Function Block: <Root>/S-Function */![]()
rtB.S_Function = my_alg(rtB.Sin);/* Outport Block: <Root>/Out */ rtY.Out = rtB.S_Function; }
In addition, wrapper.reg no longer creates a child SimStruct for the S-function because the generated code is calling my_alg directly. This eliminates over 1K of memory usage.
| TLC S-Function Wrapper | Fully Inlined S-Functions | ![]() |