How to throw an exception when using MATLAB C or C++ API

4 views (last 30 days)
I have a C++ code, which is like:
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
// Here is my code
mexErrMsgTxt("Something Wrong");
After mex the code, I want to get "Something Wrong" in MTALAB window if any exception was throwed from the "try" part.
However, if there do some errors in the code (inside the try curly bracket), it will crush my MATLAB like
The try-catch seems ineffective in this stuation. So how to throw an exception from C++ to MATLAB if anything wrong?

Answers (0)





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!