Matlab Mexception Undefined function

3 views (last 30 days)
pissed off
pissed off on 18 Jun 2014
Answered: Image Analyst on 18 Jun 2014
Hi, I'm currently attempting to add exception handling to a Matlab function (i.e. a fn defined in a *.m file) but I keep getting syntax errors; for example the following lines:
err = MException('I done a bad thing George'); throw(err);
results in the following:
??? Undefined function or method 'MException' for input arguments of type 'char'.
Error in ==> xtry at 32 err = MException('I done a bad thing George');
I'm using Matlab 7.3.0
Marcus
  1 Comment
Geoff Hayes
Geoff Hayes on 18 Jun 2014
Typically, an error message like this, Undefined function or method…, means that the function that you are trying to invoke does not exist.
In the Command Window type which MException to display the full pathname to MException. When I do this, I see the following
MException is a built-in method % MException constructor
If you see MException not found, then your version of MATLAB does not support this functionality.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 18 Jun 2014
Maybe try it like this:
try
% Some code that might generate an error.
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end

Categories

Find more on Error Handling in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!