This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Call MATLAB Functions from C/C++ MEX Files

It is possible to call MATLAB® functions, operators, user-defined functions, and other binary MEX files from within your C/C++ source code by using the API function mexCallMATLAB.

The example, sincall.c, creates an mxArray, passes various pointers to a local function to acquire data, and calls mexCallMATLAB to calculate the sine function and plot the results.

To build this example, at the command prompt type:

mex sincall.c

Run the example.


MATLAB displays a sin curve equivalent to executing the following MATLAB commands:

MAX = 1000;

mm = MAX/2;
for i = 1:mm-1
    X(i) = i*(4*3.14159/MAX);

Y = sin(X);

See Also

Related Examples

Was this topic helpful?