External Interfaces/API    

Calling Functions from C MEX-Files

It is possible to call MATLAB functions, operators, M-files, and other MEX-files from within your C source code by using the API function mexCallMATLAB. This example creates an mxArray, passes various pointers to a subfunction to acquire data, and calls mexCallMATLAB to calculate the sine function and plot the results.

Running this example

displays the results


The following example creates an M-file that returns two variables but only assigns one of them a value.

MATLAB displays the following warning message.

If you then call foo using mexCallMATLAB, the unassigned output variable will now be of type mxUNKNOWN_CLASS.


  Handling Sparse Arrays Advanced Topics