input

Purpose

Request user input.

Synopsis

x = input('prompt')
x = input('prompt','string')

Description

x = input('prompt') displays the text string prompt as a prompt on the screen, waits for input from the keyboard, and returns the value entered in x. The response can be any MATLAB expression, including function evaluation and reference to M-files. If the function produces multiple results, they are passed as multiple results from input.

x = input('prompt','string') returns the entered string as a text variable.

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

Examples

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';
end

See Also

ginput, keyboard, menu, uicontrol 

(c) Copyright 1994 by The MathWorks, Inc.