MATLAB Function Reference
  Go to function:
    Search    Help Desk 
input    Examples   See Also

Request user input

Syntax

Description

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.

Remarks

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

Examples

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

See Also

The ginput and uicontrol commands in the MATLAB Graphics Guide, and:

keyboard    Invoke the keyboard in an M-file

menu        Generate a menu of choices for user input



[ Previous | Help Desk | Next ]