问题
I know that there is no built-in way to do try-catch statements in C, but has MATLAB facilitated any type of try-catch functionality for MEX files? I tried to use Longjmp
and Setjmp
in the way described in http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html, but I was not successful. Has anyone else figured out a way?
回答1:
You can write your MEX-files in C++ and use the C++ exception handling.
来源:https://stackoverflow.com/questions/17190465/is-there-a-way-to-make-try-catch-statements-in-mex-files