Skip to Main Content Skip to Search
Product Documentation

input - Request user input

Syntax

evalResponse = input(prompt)
strResponse = input(prompt, 's')

Description

evalResponse = input(prompt) displays the prompt string on the screen, waits for input from the keyboard, evaluates any expressions in the input, and returns the value in evalResponse. To evaluate expressions, the input function accesses variables in the current workspace.

strResponse = input(prompt, 's') returns the entered text as a MATLAB string, without evaluating expressions.

Tips

Examples

Request a text response. Assign a default value ('Y') by checking for an empty matrix.

reply = input('Do you want more? Y/N [Y]: ', 's');
if isempty(reply)
    reply = 'Y';
end

See Also

ginput | inputdlg | keyboard | menu | uicontrol

  


» Learn more
» Download free kit
» Get trial software

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