Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this 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.

sincall

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);
end

Y = sin(X);
plot(X,Y)

See Also

Related Examples

Was this topic helpful?