Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

mxSetN (C and Fortran) - Set number of columns in mxArray

C Syntax

#include "matrix.h"
void mxSetN(mxArray *pm, mwSize n);

Fortran Syntax

mxSetN(pm, n)
mwPointer pm
mwSize n

Arguments

pm

Pointer to an mxArray

n

Number of columns

Description

Call mxSetN to set the number of columns in the specified mxArray. The term columns always means the second dimension of a matrix. Calling mxSetN forces an mxArray to have two dimensions. For example, if pm points to an mxArray having three dimensions, calling mxSetN reduces the mxArray to two dimensions.

You typically use mxSetN to change the shape of an existing mxArray. Note that mxSetN does not allocate or deallocate any space for the pr, pi, ir, or jc arrays. Consequently, if your calls to mxSetN and mxSetM increase the number of elements in the mxArray, you must enlarge the pr, pi, ir, and/or jc arrays.

If your calls to mxSetM and mxSetN end up reducing the number of elements in the mxArray, you may want to reduce the sizes of the pr, pi, ir, and/or jc arrays in order to use heap space more efficiently. However, reducing the size is not mandatory.

C Examples

See mxsetdimensions.c in the matlabroot/extern/examples/mx folder . For an additional example, see sincall.c in the matlabroot/extern/examples/refbook folder .

See Also

mxGetM, mxGetN, mxSetM

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS