| MATLAB Function Reference |    | 
Return last error message and related information
Syntax
Description
s = lasterror
 returns a structure s containing information about the last error issued by MATLAB. The return structure contains the following character array fields. 
| Fieldname | Description | 
| message | Text of the error message | 
| identifier | Message identifier of the error message | 
If the last error issued by MATLAB had no message identifier, then the message_id field is an empty character array.
See Message Identifiers in the MATLAB documentation for more information on the syntax and usage of message identifiers.
s = lasterror(err)
 sets the last error information to the error message and identifier specified in the structure err. Subsequent invocations of lasterror or lasterr return this new error information. The optional return structure s contains information on the previous error.
The fields of the structure err are shown in the table above. If either of these fields is undefined, MATLAB uses an empty character array instead.
Examples
lasterror is usually used in conjunction with the rethrow function in try-catch statements. For example,
See Also
error, rethrow, try, catch, lasterr, lastwarn
|   | lasterr | lastwarn |  | 
© 1994-2005 The MathWorks, Inc.