| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
h = msgbox(Message)
h = msgbox(Message,Title)
h = msgbox(Message,Title,Icon)
h = msgbox(Message,Title,'custom',IconData,IconCMap)
h = msgbox(...,CreateMode)
h = msgbox(Message) creates a message dialog box that automatically wraps Message to fit an appropriately sized figure. Message is a string vector, string matrix, or cell array. msgbox returns the handle of the message box in h.
h = msgbox(Message,Title) specifies the title of the message box.
h = msgbox(Message,Title,Icon) specifies which icon to display in the message box. Icon is 'none', 'error', 'help', 'warn', or 'custom'. The default is 'none'.

h = msgbox(Message,Title,'custom',IconData,IconCMap) defines a customized icon. IconData contains image data defining the icon. IconCMap is the colormap used for the image.
h = msgbox(...,CreateMode) specifies whether the message box is modal or nonmodal. Optionally, it can also specify an interpreter for Message and Title.
If CreateMode is a string, it must be one of the values shown in the following table.
| CreateMode Value | Description |
|---|---|
| 'modal' | Replaces the message box having the specified Title, that was last created or clicked on, with a modal message box as specified. All other message boxes with the same title are deleted. The message box which is replaced can be either modal or nonmodal. |
| 'non-modal' (default) | Creates a new nonmodal message box with the specified parameters. Existing message boxes with the same title are not deleted. |
| 'replace' | Replaces the message box having the specified Title, that was last created or clicked on, with a nonmodal message box as specified. All other message boxes with the same title are deleted. The message box which is replaced can be either modal or nonmodal. |
Note A modal dialog box prevents the user from interacting with other windows before responding. To block MATLAB program execution as well, use the uiwait function. If you open a dialog with errordlg, msgbox, or warndlg using 'CreateMode','modal' and a non-modal dialog created with any of these functions is already present and has the same name as the modal dialog, the non-modal dialog closes when the modal one opens. For more information about modal dialog boxes, see WindowStyle in the Figure Properties. |
If CreateMode is a structure, it can have fields WindowStyle and Interpreter. The WindowStyle field must be one of the values in the table above. Interpreter is one of the strings'tex' or 'none'. The default value for Interpreter is 'none'.
dialog, errordlg, helpdlg, inputdlg, listdlg, questdlg, warndlg
figure, textwrap, uiwait, uiresume
Predefined Dialog Boxes for related functions
![]() | mput | mtimes | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |