# 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.
Type: string | cell
c
Optional argument specifying the caption to be displayed for the dialog. If no caption is specified, default caption is 'Input Dialog'.
Type: string
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.
Type: int | vec | mat
values
Optional argument specifying default values to display in the text field(s). The type should be a cell array of strings.
Type: cell

## 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 contains the string(s) you entered in the text field(s). If the dialog is closed or dismissed using the 'Cancel' button, R is a cell array of empty strings, with one entry per text field.
Type: cell

## Examples

String input:
R = inputdlg('Name')
R =
{
[1,1] User name
}
The dialog displayed has one text field with the label 'Name' and caption
'Input Dialog'.
Cell input with caption and scalar dimension:
R = inputdlg({'Name', 'Address'}, 'Information', 3)
R =
{
[1,1] User name
}
The dialog displayed has two text fields with the label 'Name' and 'Address',
spanning three rows. The caption displayed is 'Information'.
Cell input with caption and vector dimension
R = inputdlg({'Name', 'Address'}, 'Information', [2, 4])
R =
{
[1,1] User name
}
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'.
Cell input with caption and matrix dimension
R = inputdlg({'Name', 'Address'}, 'Information', [1, 2; 3, 4])
R =
{
[1,1] User name
}
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'.
Cell input with caption, scalar dimension and default values:
R = inputdlg({'Name', 'Address'}, 'Information', 3, {'Username', 'Useraddress'})
R =
{
displayed is 'Information'.