User`s guide

R2007b
19-24
% Deal with the error captured in MException object, ME
- code to handle the error -
end
ME is an object of the MException class. This command gives you access to the
MException object that represents the error (i.e., exception) being caught.
Warning and Error Messages Now Wrap
In previous versions of MATLAB, warning and error messages that were longer than the
width of your terminal screen extended beyond the visible portion of your screen. These
messages now wrap onto succeeding lines so that the entire text of the warning or error
is visible.
Change to Error Message from Anonymous Function
The error message and M-file line number that MATLAB displays when encountering an
error in an anonymous function defined within a script file or at the MATLAB Command
Line has changed in this release. In MATLAB Version 7.4, the error message included
the line number (set to 1 for anonymous functions), and the stack information returned
by the lasterror function also showed the line number as 1. In MATLAB 7.5, the line
number is not displayed in the error message and is set to 0 in the returned stack
information.
For example, when you enter the following two lines at the command line, MATLAB
generates an error from the anonymous function:
X = @() error('* Error *');
X()
This example shows the difference between MATLAB Versions 7.4 and 7.5:
e = lasterror;
e.message
ans =
Error using ==> @()error('Error') at 1 % V7.4 response
Error using ==> @()error('Error') % V7.5 response
* Error *
e.stack
ans =
file: ''