External Interfaces/API    

Handling Complex Data

Complex data from MATLAB is separated into real and imaginary parts. The MATLAB API provides two functions, mxGetPr and mxGetPi, that return pointers (of type double *) to the real and imaginary parts of your data.

This example takes two complex row vectors and convolves them.

Below is the gateway routine that calls this complex convolution.

Entering these numbers at the MATLAB prompt

and invoking the new MEX-file

results in

which agrees with the results that the built-in MATLAB function conv.m produces.

  Passing Structures and Cell Arrays Handling 8-,16-, and 32-Bit Data