inputdlg
Shows a dialog box with label(s), s for text field(s) that require user input.
Syntax
R = inputdlg(s)
R = inputdlg(s, c)
R = inputdlg(s, c, dims)
R = inputdlg(s, c, dims, values)
Inputs
- s
- Label(s) for text field(s) that require user input.
- c
- Optional argument specifying the caption to be displayed for the dialog. If no caption is specified, default caption is 'Input Dialog'.
- dims
- Optional argument specifying dimensions for text field(s). If no value is given, each text field will span one row. An integer value specifies the number of rows the text fields will span over. A vector of integers specifies the number of rows each text field will span over. A matrix specifies the dimensions of each text field; the first column gives the number of rows the text field will span and the second column gives a hint for the number of columns the text field will span. All text fields will however have the same width and will span the largest number of columns in the dialog.
- values
- Optional argument specifying default values to display in the text field(s). The type should be a cell array of strings.
Outputs
- R
- The result is a cell array of strings. If the dialog is dismissed by clicking the 'OK', button or pressing 'Enter' in any text field, R will contain the string(s) entered by the user in the text field(s). If the dialog is closed or dismissed using the 'Cancel' button, R will be a cell array of empty strings, with one entry per text field.
Examples
R = inputdlg('Name')
R =
{
[1,1] User name
}
The dialog displayed has one text field with the label 'Name' and caption
'Input Dialog'.
R = inputdlg({'Name', 'Address'}, 'Information', 3)
R =
{
[1,1] User name
[2,1] User address
}
The dialog displayed has two text fields with the label 'Name' and 'Address',
spanning three rows. The caption displayed is 'Information'.
R = inputdlg({'Name', 'Address'}, 'Information', [2, 4])
R =
{
[1,1] User name
[2,1] User address
}
The dialog displayed has two text fields with the label 'Name' and 'Address'.
The 'Name' text field spans two rows and the 'Address' text field spans four
rows. The caption displayed is 'Information'.
R = inputdlg({'Name', 'Address'}, 'Information', [1, 2; 3, 4])
R =
{
[1,1] User name
[2,1] User address
}
The dialog displayed has two text fields with the label 'Name' and 'Address'.
The 'Name' text field spans one row and the 'Address' text field spans three rows.
Both text fields will span four columns, as this is the widest width. The caption
displayed is 'Information'.
R = inputdlg({'Name', 'Address'}, 'Information', 3, {'Username', 'Useraddress'})
R =
{
[1,1] Username
[2,1] Useraddress
}
The dialog displayed has two text fields with the label 'Name' and 'Address'.
Both text fields span three rows and one column. The text fields 'Name' and 'Address'
display default values of 'Username' and 'Useraddress' respectively. The caption
displayed is 'Information'.