External Interfaces/API    

Handling Complex Data

MATLAB stores complex double-precision data as two vectors of numbers -- one contains the real data and one contains the imaginary data. The API provides two functions, mxCopyPtrToComplex16 and mxCopyComplex16ToPtr, which allow you to copy the MATLAB data to a native complex*16 Fortran array.

This example takes two complex vectors (of length 3) and convolves them.

Entering these numbers at the MATLAB prompt

and invoking the new MEX-file

results in

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

  Passing Two or More Inputs or Outputs Dynamically Allocating Memory