matlab mxsetdimensions函数语法

发表matlab mxsetdimensions函数相关文章
一句话说明: Modify number of dimensions and size of each dimension

mxSetDimensions (C and Fortran)

Modify number of dimensions and size of each dimension

C Syntax

#include "matrix.h"
int mxSetDimensions(mxArray *pm, const mwSize *dims,
  mwSize ndim);

Fortran Syntax

integer*4 mxSetDimensions(pm, dims, ndim)
mwPointer pm
mwSize ndim
mwSize dims(ndim)

Arguments

pm

Pointer to an mxArray

dims

Dimensions array. Each element in the dimensions array contains the size of the array in that dimension. For example, in C, setting dims[0] to 5 and dims[1] to 7 establishes a 5-by-7 mxArray. In Fortran, setting dims(1) to 5 and dims(2) to 7 establishes a 5-by-7 mxArray. In most cases, there are ndim elements in the dims array.

ndim

Number of dimensions

Returns

0 on success, and 1 on failure. mxSetDimensions allocates heap space to hold the input size array. So it is possible (though unlikely) that increasing the number of dimensions can cause the system to run out of heap space.

Description

Call mxSetDimensions to reshape an existing mxArray. mxSetDimensions is like mxSetM and mxSetN; however, mxSetDimensions provides greater control for reshaping mxArrays that have more than two dimensions.

mxSetDimensions does not allocate or deallocate any space for the pr or pi arrays. Consequently, if your call to mxSetDimensions increases the number of elements in the mxArray, enlarge the pr (and pi, if it exists) arrays accordingly.

If your call to mxSetDimensions reduces the number of elements in the mxArray, you can optionally reduce the size of the pr and pi arrays using mxRealloc.

MATLAB® automatically removes any trailing singleton dimensions specified in the dims argument. For example, if ndim equals 5 and dims equals [4 1 7 1 1], the resulting array has the dimensions 4-by-1-by-7.

Examples

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

See Also

mxGetNumberOfDimensions, mxSetM, mxSetN, mxRealloc

欢迎转载,转载请注明来自一手册:http://yishouce.com/matlab/func/mxsetdimensions

与matlab mxsetdimensions用法相关的文章

友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1