matlab mxgetscalar函数语法

发表matlab mxgetscalar函数相关文章
一句话说明: Real component of first data element in array

mxGetScalar (C and Fortran)

Real component of first data element in array

C Syntax

#include "matrix.h"
double mxGetScalar(const mxArray *pm);

Fortran Syntax

real*8 mxGetScalar(pm)
mwPointer pm

Arguments

pm

Pointer to an mxArray; cannot be a cell mxArray, a structure mxArray, or an empty mxArray.

Returns

Pointer to the value of the first real (nonimaginary) element of the mxArray.

In C, mxGetScalar returns a double. If real elements in the mxArray are of a type other than double, mxGetScalar automatically converts the scalar value into a double. To preserve the original data representation of the scalar, cast the return value to the desired data type.

If pm points to a sparse mxArray, mxGetScalar returns the value of the first nonzero real element in the mxArray. If there are no nonzero elements, mxGetScalar returns 0.

Description

Call mxGetScalar to get the value of the first real (nonimaginary) element of the mxArray.

In most cases, you call mxGetScalar when pm points to an mxArray containing only one element (a scalar). However, pm can point to an mxArray containing many elements. If pm points to an mxArray containing multiple elements, mxGetScalar returns the value of the first real element. For example, if pm points to a two-dimensional mxArray, mxGetScalar returns the value of the (1,1) element. If pm points to a three-dimensional mxArray, mxGetScalar returns the value of the (1,1,1) element; and so on.

Use mxGetScalar on a 32-bit, nonempty mxArray of type numeric, logical, or char only. To test for these conditions, use MX Matrix Library functions such as mxIsEmpty, mxIsLogical, mxIsNumeric, or mxIsChar.

Examples

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

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

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

See Also

mxGetM, mxGetN

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

与matlab mxgetscalar用法相关的文章

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