input

Displays a message, prompt, and interrupts script execution till the user provides an input.

Syntax

R = input(prompt)

R = input(prompt, 's')

Inputs

prompt
Message or prompt to be displayed to the user.
Type: string
s (optional)
Argument which indicates that a string input is being processed and additional quotes are not needed to qualify the user's response.
Type: char

Outputs

R
The result of the evaluated input entered by the user.
Type: Any expression or data type.

Examples

Input an expression, which is evaluated:
R = input('Type the value of R here: ')
Type the value of R here: 3 * 6 + 4 * 7
R = 46
Input a string which is evaluated. So, user needs to add quotes:
R = input('What kind of an example is this? ')
What kind of an example is this? 'This is an example for the input command.'
R = This is an example for the input command.
Input a string, which is not evaluated. So, user does not need to add quotes:
R = input('How is the weather like today? ', 's')
How is the weather today? It is bright and sunny today!
R = It is bright and sunny today!

Comments

The user response may be a scalar, complex number, string, matrix, cell array or any expression. An additional argument, 's', indicates that a string input is expected from the user and quotes are not needed for the user's response.