MATLAB Programming/Entering data at the command line

From Wikibooks, open books for an open world
Jump to navigation Jump to search


The input() function lets your scripts process data entered at the command line. All input is converted into a numerical value or array. The argument for the input() function is the message or prompt you want it to display. Inputting strings require an additional 's' argument. Example:

 %test.m
 %let's ask a user for x
 x = input('Please enter a value for x:')

Then running the script would produce the output:

Please enter a value for x:3
 x = 3

 
 >>