| Real-Time Workshop® | ![]() |
| On this page… |
|---|
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 0. 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 contains either "", indicating that the current pass through the %roll is being inlined, or it is 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 the %roll directive, this is usually specified as "". |
| sigIdxoridx | 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. 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 you access these items inside a %roll, use the sigIdx generated by the %roll directive. Most functions that take a sigIdx argument accept it in an overloaded form, where sigIdx can be
Use the idx name 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 within 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 within a %roll directive, ucv and lcv are generally specified as "", and sigIdx specifies the index to access. |
| paramIdx | Parameter index. Sometimes referred to as the parameter element index. The handling of this parameter is very similar to sigIdx above: 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. |
The signal index (sigIdx sometimes written as idx) can be overloaded when passed to most library functions. Suppose you are interested in element 3 of a signal, and ucv="", lcv="". The following table shows
Values of sigIdx
Whether the signal being referenced is complex
What the function that uses sigIdx returns
An example of a returned variable
Data type of the returned variable
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 the following:
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 ii |
| "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 |
The vector index is added only for wide signals.
If ucv is not an empty string (""), then ucv is used instead of sigIdx in the above examples and both lcv and sigIdx are ignored.
If ucv is empty but lcv is not empty, then the function returns "&y%<portIdx>[%<lcv>]" and sigIdx is ignored.
It is assumed here that the roller has appropriately declared and initialized the variables accessed inside the roller. The variables accessed inside the roller should be specified using rollVars as the argument to the %roll directive.
![]() | Obsolete Functions | Input Signal Functions | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |