Target Language Compiler    

Target Language Compiler Functions

This section lists the Target Language Compiler functions grouped by category, and provides a description of each function. To view the source code for a function, click on its name.

Common Function Arguments

Several functions take similar or identical arguments. To simplify the reference pages, some of these arguments are documented in detail here instead of in the reference pages.

Argument
Description
portIdx
Refers to an input or output port index, starting at zero. For example the first input port of an S-function is 0.
ucv
User control variable. This is an advanced feature that overrides the lcv and sigIdx parameters. When used within an inlined S-function, it should generally be specified as "".
lcv
Loop control variable. This is generally generated by the %roll directive via the second %roll argument (e.g., lcv=RollThreshold) and should be passed directly to the library function. It will contain either "", indicating that the current pass through the %roll is being inlined, or it will be the name of a loop control variable such as "i", indicating that the current pass through the %roll is being placed in a loop. Outside of the %roll directive, this is usually specified as "".
sigIdx
or
idx
Signal index. Sometimes referred to as the signal element index. When accessing specific elements of an input or output signal directly, the call to the various library routines should have ucv="", lcv="", and sigIdx equal to the desired integer signal index starting at 0. Note, for complex signals, sigIdx can be an overloaded integer index specifying both whether the real or imaginary part is being accessed and which element. When accessing these items inside of a %roll, the sigIdx generated by the %roll directive should be used.

Most functions that take a sigIdx argument accept it in an overloaded form where sigIdx can be:
  • An integer, e.g. 3. If the referenced signal is complex, then this refers to the identifier for the complex container. If the referenced signal is not complex, then this refers to the identifier.
  • An id-num usually of the form (see Overloading sigIdx):
    1. "%<tRealPart>%<idx>" (e.g., "re3"). The real part of the signal element. Usually "%<tRealPart>%<sigIdx>" when sigIdx is generated by the %roll directive.
    2. "%<tImagPart>%<idx>" (e.g., "im3"). The imaginary part of the signal element or "" if the signal is not complex. Usually "%<tImagPart>%<sigIdx>" when sigIdx is generated by the %roll directive.
The idx name is used when referring to a state or work vector.
Functions that accept the three arguments ucv, lcv, sigIdx (or idx) are called differently depending upon whether or not they are used with in a %roll directive. If they are used within a %roll directive, ucv is generally specified as "" and lcv and sigIdx are the same as those specified in the %roll directive. If they are not used with in a %roll directive, ucv and lcv are generally specified as "" and sigIdx specifies which index to access.
paramIdx
Parameter index. Sometimes referred to as the parameter element index. The handling of this parameter is very similar to sigIdx (i.e., it can be #, re#, or im#).
stateIdx
State index. Sometimes referred to as the state vector element index. It must evaluate to an integer where the first element starts at 0.

Overloading sigIdx

The signal index (sigIdx sometimes written as idx) can be overloaded when passed to most library functions. Suppose we are interested in element 3 of a signal, and ucv="", lcv="". The following table shows:

Note that "container" in the following table refers to the object that encapsulates both the real and imaginary parts of the number, e.g., creal_T defined in matlabroot/extern/include/tmwtypes.h.

sigIdx
Complex
Function Returns
Example
Data
Type

"re3"
yes
Real part of element 3
u0[2].re
real_T
"im3"
yes
Imaginary part of element 3
u0[2].im
real_T
"3"
yes
Complex container of element 3
u0[2]
creal_T
3
yes
Complex container of element 3
u0[2]
creal_T
"re3"
no
Element 3
u0[2]
real_T
"im3"
no
" "
N/A
N/A
"3"
no
Element 3
u0[2]
real_T
3
no
Element 3
u0[2]
real_T

Now suppose:

  1. We are interested in element 3 of a signal
  2. (ucv = "i" AND lcv == "") OR (ucv = "" AND lcv = "i")

The following table shows values of idx, whether the signal is complex, and what the function that uses idx returns.

sigIdx
Complex
Function Returns
"re3"
yes
Real part of element i
"im3"
yes
Imaginary part of element i
"3"
yes
Complex container of element i
3
yes
Complex container of element i
"re3"
no
Element i
"im3"
no
" "
"3"
no
Element i
3
no
Element i

Notes


  Obsolete Functions Input Signal Functions