MATLAB Function Reference Previous page   Next Page

Request user input



The response to the input prompt can be any MATLAB expression, which is evaluated using the variables in the current workspace.

user_entry = input('prompt') displays prompt as a prompt on the screen, waits for input from the keyboard, and returns the value entered in user_entry.

user_entry = input('prompt', 's') returns the entered string as a text variable rather than as a variable name or numerical value.


If you press the Return key without entering anything, input returns an empty matrix.

The text string for the prompt can contain one or more '\n' characters. The '\n' means to skip to the next line. This allows the prompt string to span several lines. To display just a backslash, use '\\'.

If you enter an invalid expression at the prompt, MATLAB displays the relevant error message and then prompts you again to enter input.


Press Return to select a default value by detecting an empty matrix:

See Also

keyboard, menu, ginput, uicontrol

Previous page  inpolygon inputdlg Next page

© 1994-2005 The MathWorks, Inc.