MATLAB Application Program Interface Reference | Help Desk |
mxIsComplex
True if data is complex
#include "matrix.h" bool mxIsComplex(const mxArray *array_ptr);
true
if array_ptr
is a numeric array containing complex data; otherwise, returns false
. If array_ptr
points to a cell array or a structure array, then mxIsComplex
returns false
.
Use mxIsComplex
to determine whether or not an imaginary part is allocated for an mxArray
. The imaginary pointer pi
is NULL
if an mxArray
is purely real and does not have any imaginary data. If an mxArray
is complex, pi
points to an array of numbers.
When a MEX-file is called, MATLAB automatically examines all the input (right-hand side) arrays. If any input array is complex, then MATLAB automatically allocates memory to hold imaginary data for all other input arrays. For example, suppose a user passes three input variables (apricot
, banana
, and carambola
) to a MEX-file named Jest
:
>> apricot = 7; >> banana = sqrt(-5:5); >> carambola = magic(2); >> Jest(apricot, banana, carambola);
banana
is complex. Therefore, even though array apricot
is purely real, MATLAB automatically allocates space (one element) to hold an imaginary value of apricot
. MATLAB also automatically allocates space (four-elements) to hold the nonexistent imaginary values of carambola
.
In other words, MATLAB forces every input array to be real or every input array to be complex.
See mxIsComplex.c
in the mx
subdirectory of the examples
directory.
mxIsNumeric