User`s guide

Writing Wrapper S-Functions
4-17
The final step is the actual inlining of the call to the function my_alg.Thisis
done by the
Outputs function. In this function, you load the input and output
and call place a direct call to
my_alg. The call is embedded in wrapper.c.
The Inlined Code
The code generated wh en you inline your wrapp er S-function is similar to the
defaultgenerated code. The
MdlTerminate functi on 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;
}
Inaddition,wrapper.reg nolongercreatesachildSimStruct for theS-function
since the generated code i s calling
my_alg directly. T his eliminates over 1K of
memory usage.
Inlined call to the
function my_alg.