Programming and Data Types    

Displaying Error and Warning Messages

Use the error and fprintf functions to display error information on the screen. The error function has the syntax

If you call the error function from inside an M-file, error displays the text in the quoted string and causes the M-file to stop executing. For example, suppose the following appears inside the M-file myfile.m.

For n equal to 0, the following text appears on the screen and the M-file stops.

In MATLAB, warnings are similar to error messages, except program execution does not stop. Use the warning function to display warning messages.

The function lastwarn displays the last warning message issued by MATLAB.


 Errors and Warnings Dates and Times