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.
- s (optional)
- Argument which indicates that a string input is being processed and additional quotes are not needed to qualify the user's response.
Outputs
- R
- The result of the evaluated input entered by the user.
Examples
R = input('Type the value of R here: ')
Type the value of R here: 3 * 6 + 4 * 7
R = 46
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.
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.