Register function to call when MEX-function clears or MATLAB terminates
#include "mex.h" int mexAtExit(void (*ExitFcn)(void));
#include "fintrf.h" integer*4 mexAtExit(ExitFcn) subroutine ExitFcn()
Pointer to function you want to run on exit
mexAtExit to register a function to
call just before clearing the MEX-function or terminating MATLAB®.
your MEX-function a chance to perform tasks such as freeing persistent
memory and closing files. Other typical tasks include closing streams
Each MEX-function can register only one active exit function
at a time. If you call
mexAtExit more than once, MATLAB uses
ExitFcn from the more recent
as the exit function.
If a MEX-function is locked, you cannot clear the MEX-file.
Consequently, if you attempt to clear a locked MEX-file, MATLAB does
not call the
In Fortran, declare the
the Fortran routine that calls
mexAtExit if it
is not within the scope of the file.