MATLAB Function Reference | Search  Help Desk |
input | Examples See Also |
user_entry = input('The response to theprompt
') user_entry = input('prompt
','s')
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:
i = input('Do you want more? Y/N [Y]: ','s'); if isempty(i) i = 'Y'; endThe
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