External Interfaces Previous page   Next Page

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


Figure showing a sine wave

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.


Previous page  Handling Sparse Arrays Advanced Topics Next page

© 1994-2005 The MathWorks, Inc.