Get the number of rows
C Syntax
#include "matrix.h"
int mxGetM(const mxArray *array_ptr);
Arguments
array_ptr
Pointer to an array.
Returns
The number of rows in the mxArray
to which array_ptr
points.
Description
mxGetM
returns the number of rows in the specified array. The term "rows" always means the first dimension of the array no matter how many dimensions the array has. For example, if array_ptr
points to a four-dimensional array having dimensions 8-by-9-by-5-by-3, then mxGetM
returns 8.
Examples
Consider a MEX-file that accepts two input mxArray
arguments. Both mxArray
arguments must have the same number of rows in order for the calculation to work.
void
mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray
*prhs[])
{
int rows;
rows = mxGetM(prhs[0]);
if (rows != 1)
mexErrMsgTxt("First input array must be a vector.");
else
...
For an additional example, see mxgetm.c
in the mx
subdirectory of the examples
directory.
See Also
mxGetN
, mxSetM
, mxSetN
[ Previous | Help Desk | Next ]