Throw error and display message
error(
includes an error identifier on the exception. The identifier enables you to
distinguish errors and to control what happens when MATLAB encounters the errors. You can include any of the input arguments
in the previous syntaxes.errID
,___)
error(
throws an error
using the fields in a scalar structure.errorStruct
)
error(
provides a suggested fix for the exception. You can include any of the input
arguments in the previous syntaxes. correction
,___)
When you throw an error, MATLAB captures information about it and stores it in a data structure
that is an object of the MException
class. You can access
information in the exception object by using try/catch
. Or,
if your program terminates because of an exception and returns control to the
Command Prompt, you can use MException.last
.
MATLAB does not cease execution of a program if an error occurs within a
try
block. In this case, MATLAB passes control to the catch
block.
If all inputs to error
are empty, MATLAB does not throw an error.
assert
| dbstack
| errordlg
| MException
| MException.last
| try
| warning