Using the C Math Library    

Calling the Indexing Functions 

Each indexing function requires at least three arguments; mlfIndexAssign() requires at least four. The first argument is the array to which the indexing operation is being applied. Since both mlfIndexAssign() and mlfIndexDelete() modify the array, the first argument to these functions must be an mxArray**; as mlfIndexRef() does not modify the array, its first argument is an mxArray*.

The second argument is a string describing the indexing operation. This string uses a simplification of the MATLAB indexing syntax; (), {} and .field (depending on what type of indexing you're doing) are required, but the actual values that would appear in a MATLAB index operation are replaced by ?'s in the MATLAB C Math Library. For example, the MATLAB expression x{3}(2,4,2).color (a combination of cell array, standard, and structure indexing) results in the following string: "{?}(?,?,?).color".

The third and subsequent arguments are the values to use in place of the ?'s in the string. These values must be mxArray*'s and are very often the result of a call to mlfScalar(), which creates an mxArray* from a double-precision floating-point number or a integer.

When calling mlfIndexAssign(), the last argument in the list is the source array that contains the values to write into the target array. Note that the source array must be exactly the same size as the subset of the target array specified by the indexing expression in the second argument and subsequent arguments.

Refer to the online MATLAB C Math Library Reference for more detail on the interface for the three functions.


 Array Storage Specifying the Target Array