External Interfaces/API Reference | ![]() ![]() |
C Syntax
#include "matrix.h" bool mxIsComplex(const mxArray *array_ptr);
Returns
true
if array_ptr
is a numeric array containing complex data, and false
otherwise. If array_ptr
points to a cell array or a structure array, then mxIsComplex
returns false
.
Description
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 you pass 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.
Examples
See mxisfinite.c
in the mx
subdirectory of the examples
directory.
For additional examples, see convec.c
, phonebook.c
, timestwo.c
, and xtimesy.c
in the refbook
subdirectory of the examples
directory; see explore.c
, yprime.c
, mexlock.c
, and mexsettrapflag.c
in the mex
subdirectory of the examples
directory; see mxcalcsinglesubscript.c
, mxgeteps.c
, and mxgetinf.c
in the mx
subdirectory of the examples
directory.
See Also
![]() | mxIsClass | mxIsDouble | ![]() |