| Contents | Index |
#include "matrix.h"
mwIndex mxCalcSingleSubscript(const mxArray *pm, mwSize nsubs,
mwIndex *subs);
mwIndex mxCalcSingleSubscript(pm, nsubs, subs) mwPointer pm mwSize nsubs mwIndex subs
Pointer to an mxArray
Number of elements in the subs array. Typically, you set nsubs equal to the number of dimensions in the mxArray that pm points to.
An array of integers. Each value in the array specifies that dimension's subscript. In C syntax, the value in subs[0] specifies the row subscript, and the value in subs[1] specifies the column subscript. Use zero-based indexing for subscripts. For example, to express the starting element of a two-dimensional mxArray in subs, set subs[0] to 0 and subs[1] to 0.
In Fortran syntax, the value in subs(1) specifies the row subscript, and the value in subs(2) specifies the column subscript. Use 1-based indexing for subscripts. For example, to express the starting element of a two-dimensional mxArray in subs, set subs(1) to 1 and subs(2) to 1.
The number of elements, or index, between the start of the mxArray and the specified subscript. This is the linear index equivalent of the subscripts. Many MX Matrix Library routines (for example, mxGetField) require an index as an argument.
If subs describes the starting element of an mxArray, mxCalcSingleSubscript returns 0. If subs describes the final element of an mxArray, mxCalcSingleSubscript returns N-1 (where N is the total number of elements).
Call mxCalcSingleSubscript to determine how many elements there are between the beginning of the mxArray and a given element of that mxArray. The function converts subscripts to linear indices.
For example, given a subscript like (5,7), mxCalcSingleSubscript returns the distance from the first element of the array to the (5,7) element. Remember that the mxArray data type internally represents all data elements in a one-dimensional array no matter how many dimensions the MATLAB mxArray appears to have. For examples showing the internal representation, see Data Storage in the External Interfaces documentation.
Avoid using mxCalcSingleSubscript to traverse the elements of an array. In C, it is more efficient to do this by finding the array's starting address and then using pointer autoincrementing to access successive elements. For example, to find the starting address of a numerical array, call mxGetPr or mxGetPi.
See the following examples in matlabroot/extern/examples/mx.

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |