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 see the example, open the fileopen the file in MATLAB Editor.
To build this example, at the command prompt type:
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); end Y = sin(X); plot(X,Y)