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.

MEX Library API

Use this library to perform operations in the MATLAB® environment from C/C++ and Fortran MEX files

Use mexFunction in a MEX file like you would main or subroutine in C/C++ or Fortran programs. To call a MATLAB function, use mexCallMATLAB or mexEvalString. To pass data between the MEX file and the MATLAB workspace, use the mexGet* and mexSet* functions.

C MEX Library Functions

mexFunction Entry point to C/C++ or Fortran MEX file
mexFunctionName Name of current MEX function
mexAtExit Register function to call when MEX function clears or MATLAB terminates
mexCallMATLAB Call MATLAB function, user-defined function, or MEX file
mexCallMATLABWithTrap Call MATLAB function, user-defined function, or MEX-file and capture error information
mexEvalString Execute MATLAB command in caller workspace
mexEvalStringWithTrap Execute MATLAB command in caller workspace and capture error information
mexGet Value of specified graphics property
mexSet Set value of specified graphics property
mexGetVariable Copy of variable from specified workspace
mexGetVariablePtr Read-only pointer to variable from another workspace
mexPutVariable Array from MEX-function into specified workspace
mexPrintf ANSI C PRINTF-style output routine
mexSetTrapFlag Control response of MEXCALLMATLAB to errors
mexErrMsgIdAndTxt Display error message with identifier and return to MATLAB prompt
mexWarnMsgIdAndTxt Warning message with identifier
mexErrMsgTxt Display error message and return to MATLAB prompt
mexWarnMsgTxt Warning message
mexIsLocked Determine if MEX-file is locked
mexLock Prevent clearing MEX-file from memory
mexUnlock Allow clearing MEX-file from memory
mexMakeArrayPersistent Make array persist after MEX file completes
mexMakeMemoryPersistent Make memory allocated by MATLAB software persist after MEX-function completes

Fortran MEX Library Functions

mexFunction Entry point to C/C++ or Fortran MEX file
mexFunctionName Name of current MEX function
mexAtExit Register function to call when MEX function clears or MATLAB terminates
mexCallMATLAB Call MATLAB function, user-defined function, or MEX file
mexCallMATLABWithTrap Call MATLAB function, user-defined function, or MEX-file and capture error information
mexEvalString Execute MATLAB command in caller workspace
mexEvalStringWithTrap Execute MATLAB command in caller workspace and capture error information
mexGetVariable Copy of variable from specified workspace
mexGetVariablePtr Read-only pointer to variable from another workspace
mexPutVariable Array from MEX-function into specified workspace
mexPrintf ANSI C PRINTF-style output routine
mexSetTrapFlag Control response of MEXCALLMATLAB to errors
mexErrMsgIdAndTxt Display error message with identifier and return to MATLAB prompt
mexWarnMsgIdAndTxt Warning message with identifier
mexErrMsgTxt Display error message and return to MATLAB prompt
mexWarnMsgTxt Warning message
mexIsLocked Determine if MEX-file is locked
mexLock Prevent clearing MEX-file from memory
mexUnlock Allow clearing MEX-file from memory
mexMakeArrayPersistent Make array persist after MEX file completes
mexMakeMemoryPersistent Make memory allocated by MATLAB software persist after MEX-function completes
Was this topic helpful?