Display alert dialog box
displays a modal dialog box in front of the specified figure window. The figure must
be created with the
uifigure function. The dialog box
displays the specified message and has a title bar with the specified title. By
default, the dialog box also contains an error icon and an OK
Create a modal alert dialog box. The figure behind it is inaccessible until you close the dialog box.
fig = uifigure; uialert(fig,'File not found','Invalid File');
fig = uifigure; message = sprintf('Fire hazard! \n Consider reducing temperature.'); uialert(fig,message,'Warning',... 'Icon','warning');
fig— Target figure
Target figure, specified as a
Figure object. The figure
must be created with the
Message, specified as a character vector, cell array of character vectors, or string array. The message can be any length.
Format characters such as the newline character (
are honored. To display multiple lines of text, use a cell array of
character vectors or a string array.
'Error'(default) | character vector | string scalar
Title, specified as a character vector or string scalar. Long titles truncate and are followed by ellipses. The exact length at which a title is truncated depends on your system setup.
Spaces replace format characters, such as the newline
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'CloseFcn'— Alert dialog box close request function callback
''(default) | function handle | cell array | character vector
The alert dialog box close request callback function, specified as one of these values:
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector that is a valid MATLAB® expression. MATLAB evaluates this expression in the base workspace.
CloseFcn callback executes when the app user
dismisses the alert dialog box by clicking the close button in the title
bar or clicking the OK button. The
CloseFcn function also executes when the app
user closes the figure window for which the alert dialog box displays
from the MATLAB command line. You can close a figure window from the
command line using the
'error'(default) | predefined icon | custom icon
Icon, specified as a predefined icon or a custom icon.
This table lists the values for the predefined icons. For example,
to show the check mark icon, specify the name-value pair
No icon displays.
Specify a custom icon as one of these values:
A character vector that specifies the file name of an SVG, JPEG, GIF, or PNG image that is on the MATLAB path. Alternatively, you can specify a full path to the image file.
A truecolor image array. See Image Types for more information.
Modal, specified as
A modal dialog box is one that makes the figure inaccessible until the dialog box is closed. However, it does not prevent additional dialog boxes from appearing.