Writing S-Functions    

Fully Inlined S-Functions

Continuing the example of the previous section, you could eliminate the call to my_alg entirely by specifying the explicit code (i.e., 2.0 * u) in wrapsfcn.tlc. This is referred to as a fully inlined S-function. While this can improve performance, if your C code is large this can be a lengthy task. In addition, you now have to maintain your algorithm in two places, the C S-function itself and the corresponding TLC file. However, the performance gains might outweigh the disadvantages. To inline the algorithm used in this example, in the Outputs section of your wrapsfcn.tlc file, instead of writing

use

This is the code produced in mdlOutputs:

The Target Language Compiler has replaced the call to my_alg with the algorithm itself.


  The Inlined Code Multiport S-Function Example