Exception” on page 26-19 and “Throw an Exception” on page 26-16. All are read-only;
their values cannot be changed.
The MException properties are:
- identifier on page 26-8
- message on page 26-10
- stack on page 26-11
- cause on page 26-12
- Correction on page 26-13
If you call the surf function with no inputs, MATLAB throws an exception. If you catch
the exception, you can see the properties of the MException object structure. (This
example uses try/catch in an atypical fashion. See the section on “The try/catch
Statement” on page 26-19 for more information on using try/catch).
try
surf
catch ME
ME
end
Run this at the command line and MATLAB returns the contents of the MException
object:
ME =
MException with properties:
identifier: 'MATLAB:narginchk:notEnoughInputs'
message: 'Not enough input arguments.'
cause: {}
stack: [1×1 struct]
Correction: []
The stack field shows the filename, function, and line number where the exception was
thrown:
ME.stack
ans =
file: 'matlabroot\toolbox\matlab\graph3d\surf.m'
name: 'surf'
line: 54
Capture Information About Exceptions