questdlg

Shows a dialog box with a question s. By default, the dialog displayed will have the 'Yes', 'No' and 'Cancel' buttons.

Syntax

R = questdlg(s)

R = questdlg(s, c)

R = questdlg(s, c, defaultButton)

R = questdlg(s, c, button1, button2, defaultButton)

R = questdlg(s, c, button1, button2, button3, defaultButton)

Inputs

s
Content to display in the dialog. String inputs can have the '\n' newline character, which are displayed on separate lines of the dialog. String elements of cell inputs will be displayed on new lines in the dialog.
Type: string | cell
c (optional)
Specifies the caption to be displayed for the dialog. If no caption is specified, the caption displayed is 'Question'.
Type: string
defaultButton (optional)
The default button that is applied when the 'Enter' key is pressed. defaultButton must match the text of other buttons in the dialog.
Type: string
button1 (optional)
Specifies the text displayed for the first button in the dialog. The default text displayed is 'Yes'.
Type: string
button2 (optional)
Specifies the text displayed for the second button in the dialog. The default text displayed is 'No'.
Type: string
button3 (optional)
Specifies the text displayed for the third button in the dialog. If button3 is empty, the button is not displayed. The default text of the displayed button is 'Cancel'.
Type: string

Outputs

R
R contains the text of the button you select.
Type: string

Examples

Cell input with a caption:
R = questdlg({'Is', 'this', 'a', 'test?'}, 'Test')

R = Yes
Content displayed in the dialog with caption 'Test' is
'Is'
'this'
'a'
'test'
String input with caption and default button option:
R = questdlg('Is this a test?', 'Test', 'No')

R = No
Content displayed in the dialog with the caption 'Test' is
'Is this a test?'
String input with customized buttons and default option:
R = questdlg('How is the weather?', 'Weather', 'Sunny', 'Cloudy', 'Unpredictable', 'Unpredictable')

R = Unpredictable
Content displayed in the dialog with the caption 'Weather', with buttons 'Sunny',
'Cloudy' and 'Unpredictable' is 'How is the weather?'