MATLAB Application Program Interface
  Go to function:
    Search    Help Desk 
mxSetM    Examples   See Also

Set the number of rows

C Syntax

Arguments

m
  The desired number of rows.

array_ptr
  Pointer to an mxArray.

Description

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. Note that mxSetM does not allocate or deallocate any space for the pr, pi, ir, or jc arrays. Consequently, if your calls to mxSetM and mxSetN increase the number of elements in the mxArray, then you must enlarge the pr, pi, ir, and/or jc arrays. Call mxRealloc to enlarge them. (See the mxSetN reference page for an example of doing this.)

If your calls to mxSetM and mxSetN end up reducing the number of elements in the array, then you do can optionally reduce the sizes of the pr, pi, ir, and/or jc arrays in order to use heap space more efficiently.

Examples

Reshape a 3-by-2 mxArray into a 6-by-1 mxArray for more efficient use of memory without changing the data held by the mxArray.

The data in Apricot starts out as

After reshaping, Apricot's data becomes

For an additional example, see mxsetm.c in the mx subdirectory of the examples directory.

See Also

mxGetM, mxGetN, mxSetN



[ Previous | Help Desk | Next ]