Documentation Center

  • Trial Software
  • Product Updates

last (MException)

Last uncaught exception


exception = MException.last


exception = MException.last displays the contents of the MException object representing your most recent uncaught error. This is a static method of the MException class; it is not a method of an MException instance.

    Note:   Use this method from the MATLAB® command line only, and not within a function.

MException.last('reset') sets the identifier and message properties of the exception retrieved by MException.last to the empty string, the stack property to a 0-by-1 structure, and cause property to an empty cell array.

MException.last is not set if an exception is caught by a try, catch statement.


This example displays the last error that was caught during this MATLAB session:

A = 25;
??? Index exceeds matrix dimensions.

ans =

	MException object with properties:

    identifier: 'MATLAB:badsubscript'
       message: 'Index exceeds matrix dimensions.'
         stack: [0x1 struct]
         cause: {}

See Also

| | | | | | | |

Was this topic helpful?