MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS Guida Utente Pagina 183

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 210
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 182
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.
Vedere la pagina 182
1 2 ... 178 179 180 181 182 183 184 185 186 187 188 ... 209 210

Commenti su questo manuale

Nessun commento