User`s manual
Examples of C MEX-Files
2-23
/* Call the C subroutine. */
convec(xr, xi, nx, yr, yi, ny, zr, zi);
return;
}
Entering 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];
and invoking the new MEX-file
z = convec(x,y)
results in
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
which agrees with the results that the built-in MATLAB function conv.m
produces.
Handling 8-,16-, and 32-Bit Data
You can create and manipulate signed and unsigned 8-, 16-, and 32-bit data
from within your MEX-files. The MATLAB API provides a set of functions that
support these data types. The API function
mxCreateNumericArray constructs
an unpopulated N-dimensional numeric array with a specified data size. Refer
to the entry for
mxClassID in the online reference pages for a discussion of how
the MATLAB API represents these data types.
Once you have created an unpopulated MATLAB array of a specified data type,
you can access the data using
mxGetData and mxGetImagData. These two
functions return pointers to the real and imaginary data. You can perform