If this function receives invalid arguments, MATLAB throws an error message and stops
the program:
combinations(6,9)
Error using combinations (line 3)
Cannot choose 9 from 6 elements
Add Identifiers to Warnings and Errors
A message identifier provides a way to uniquely reference a warning or an error.
Enable or disable warnings with identifiers. Use an identifying text argument with the
warning function to attach a unique tag to a message:
warning(identifier_text,message_text)
For example, you can add an identifier tag to the previous MATLAB warning about which
version of software is running:
minver = '7';
if ~strncmp(version,minver,1)
warning('MYTEST:VERCHK','Running a version other than v%s',minver)
end
Adding an identifier to an error message allows for negative testing. However, adding and
recovering more information from errors often requires working with MException
objects.
See Also
MException | lastwarn | warndlg | warning
Related Examples
- “Suppress Warnings” on page 26-34
- “Restore Warnings” on page 26-37
- “Capture Information About Exceptions” on page 26-5
- “Exception Handling in a MATLAB Application” on page 26-2
26 Error Handling