MATLAB Function Reference    

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 may 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 '\\'.


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

See Also

keyboard, menu, ginput, uicontrol

  inpolygon inputdlg