MATLAB Application Program Interface Reference | Help Desk |
engClose
Quit a MATLAB engine session
#include "engine.h" int engClose(Engine *ep);
ep
This routine allows you to quit a MATLAB engine session.
engClose
sends a quit command to the MATLAB engine session and closes the connection. It returns 0 on success, and 1 otherwise. Possible failure includes attempting to terminate a MATLAB engine session that was already terminated.
Kill a MATLAB engine on the UNIX machine that you are currently logged into:
Kill a MATLAB engine on a Windows machine:/
*engtest2.c
*/
#include <stdio.h> #include <stdlib.h> #include "engine.h" void main() { ep = engOpen(""); if (ep == NULL) { fprintf(stderr, "Unable to start MATLAB session\n"); exit(EXIT_FAILURE); } }
/*ENGTEST2*/ #include <stdlib.h> #include <stdio.h> #include "engine.h" int WINAPI WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { Engine *ep; if (!(ep = engOpen())) { MessageBox ((HWND)NULL, (LPSTR)"Can't start MATLAB engine", (LPSTR) "Engtest2.c", MB_OK); } engClose(ep); return (TRUE); }See
engdemo.c
in the eng_mat
subdirectory of the examples
directory for a sample program that illustrates how to call the MATLAB engine functions from a C program.