Throw error if condition false
When you issue 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
.
If an assertion failure occurs within a try
block, MATLAB does
not cease execution of the program. In this case, MATLAB passes
control to the catch
block.