inputdlg - Create and open input dialog box

Syntax

answer = inputdlg(prompt)
answer = inputdlg(prompt,dlg_title)
answer = inputdlg(prompt,dlg_title,num_lines)
answer = inputdlg(prompt,dlg_title,num_lines,defAns)
answer = inputdlg(prompt,dlg_title,num_lines,defAns,options)

Description

answer = inputdlg(prompt) creates a modal dialog box and returns user input for multiple prompts in the cell array. prompt is a cell array containing prompt strings.

answer = inputdlg(prompt,dlg_title) dlg_title specifies a title for the dialog box.

answer = inputdlg(prompt,dlg_title,num_lines) num_lines specifies the number of lines for each user-entered value. num_lines can be a scalar, column vector, or matrix.

answer = inputdlg(prompt,dlg_title,num_lines,defAns) defAns specifies the default value to display for each prompt. defAns must contain the same number of elements as prompt and all elements must be strings.

answer = inputdlg(prompt,dlg_title,num_lines,defAns,options) If options is the string 'on', the dialog is made resizable in the horizontal direction. If options is a structure, the fields shown in the following table are recognized:

Field

Description

Resize

Can be 'on' or 'off' (default). If 'on', the window is resizable horizontally.

WindowStyle

Can be either 'normal' or 'modal' (default).

Interpreter

Can be either 'none' (default) or 'tex'. If the value is 'tex', the prompt strings are rendered using LaTeX.

If the user clicks the Cancel button to close an inputdlg box, the dialog returns an empty cell array:

answer = 
     {}

Example

Example 1

Create a dialog box to input an integer and colormap name. Allow one line for each value.

prompt = {'Enter matrix size:','Enter colormap name:'};
dlg_title = 'Input for peaks function';
num_lines = 1;
def = {'20','hsv'};
answer = inputdlg(prompt,dlg_title,num_lines,def);

Example 2

Create a dialog box using the default options. Then use the options to make it resizable and not modal, and to interpret the text using LaTeX.

prompt={'Enter the matrix size for x^2:',...
        'Enter the colormap name:'};
name='Input for Peaks function';
numlines=1;
defaultanswer={'20','hsv'};
answer=inputdlg(prompt,name,numlines,defaultanswer);

options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';

answer=inputdlg(prompt,name,numlines,defaultanswer,options);

See Also

dialog, errordlg, helpdlg, listdlg, msgbox, questdlg, warndlg

figure, uiwait, uiresume

Predefined Dialog Boxes for related functions

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS