C Math Library Reference | ![]() ![]() |
Extract elements specified by the subscript from the target array and return the result in a new mxArray
C Prototype
mxArray *mlfIndexRef(mxArray *pa, const char* index_string, ...);
Arguments
mxArray *pa
Specifies the array that you want to extract elements from.
"(?,?)"
. mlfIndexRef()
does not use index values specified in the subscript string.
mxArray* arguments
You do not need to terminate the list of arguments with NULL
; the indexing functions can detect the number of expected arguments.
Return
Returns a pointer to a new mxArray
that contains the extracted data.
Description
mlfIndexRef()
, along with mlfIndexAssign()
and mlfIndexDelete()
, provides access to array elements in the MATLAB C Math Library. These routines emulate the MATLAB indexing operator ()
.
mlfIndexRef()
copies the value of an array element into another array; it does not modify the element in the target array. To assign a value to an array element, use mlfIndexAssign()
. To delete the value of an array element, use mlfIndexDelete()
.
Example
This code selects the element at row 2, column 2 in array A
and returns it in B
.
/* In MATLAB: B = A(2,2) */ mxArray *B = NULL; mlfAssign(&B, mlfIndexRef(A, /* Target array */ "(?,?)", /* Index format string */ mlfScalar(2), /* Subscript value */ mlfScalar(2))); /* Subscript value */
See Also
mlfIndexAssign, mlfIndexDelete
![]() | mlfIndexDelete | mlfIndexVarargout | ![]() |