error
Throw error and display message
Description
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
,___)
Examples
Input Arguments
Tips
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 usingtry/catch
. Or, if your program terminates because of an exception and returns control to the Command Prompt, you can useMException.last
.MATLAB does not cease execution of a program if an error occurs within a
try
block. In this case, MATLAB passes control to thecatch
block.If all inputs to
error
are empty, MATLAB does not throw an error.
Extended Capabilities
Version History
Introduced before R2006a
See Also
MException
| MException.last
| warning
| errordlg
| assert
| dbstack
| try
| sprintf