Documentation

Handle Complex Data

MATLAB® separates complex data 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, convec.c, takes two complex row vectors and convolves them.

To build this example, at the command prompt type:

mex convec.c

Enter these numbers at the MATLAB prompt.

x = [3.000 - 1.000i, 4.000 + 2.000i, 7.000 - 3.000i];
y = [8.000 - 6.000i, 12.000 + 16.000i, 40.000 - 42.000i];

Call the MEX-file.

z = convec(x,y)
z =
   1.0e+02 *

Columns 1 through 4 

0.1800 - 0.2600i 0.9600 + 0.2800i 1.3200 - 1.4400i 3.7600 - 0.1200i

Column 5 

1.5400 - 4.1400i

Compare the results with the built-in MATLAB function conv.

See Also

|

Related Examples

Was this topic helpful?