This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mxSetM (C and Fortran)

Set number of rows in array

C Syntax

#include "matrix.h"
void mxSetM(mxArray *pm, mwSize m);

Fortran Syntax

#include "fintrf.h"
subroutine mxSetM(pm, m)
mwPointer pm
mwSize m



Pointer to an mxArray


Number of rows


Call mxSetM to set the number of rows in the specified mxArray. The term rows means the first dimension of an mxArray, regardless of the number of dimensions. Call mxSetN to set the number of columns.

You typically use mxSetM to change the shape of an existing mxArray. The mxSetM function does not allocate or deallocate any space for the pr, pi, ir, or jc arrays. So, if your calls to mxSetM and mxSetN increase the number of elements in the mxArray, enlarge the pr, pi, ir, and/or jc arrays. Call mxRealloc to enlarge them.

If calling mxSetM and mxSetN reduces the number of elements in the mxArray, you might want to reduce the sizes of the pr, pi, ir, and/or jc arrays to use heap space more efficiently. However, reducing the size is not mandatory.


See the following examples in matlabroot/extern/examples/mx.

See the following examples in matlabroot/extern/examples/refbook.

Introduced before R2006a

Was this topic helpful?