Input/Output and File Statements in MATLAB

Leave a Comment
MATLAB

Input / Output is possible in various forms in MATLAB. There are numerous functions for sending data to the Standard output device (monitor) and for reading data from the standard input device (keyboard). 
In MATLAB, there are three methods to assign a value to a variable:
Using the assignment (=) statement
Read the data from a file stored in the system
Take the value as an input from the user

Input() Function
To accept data from the user, one can use input() function.

R = input(‘Enter the Radius of the circle: ‘);


When this statement is executed, the string ‘Enter the Radius of the circle: ‘ is printed on the screen and the system waits for the user to enter a value. The data accepted is stored in the variable R. Notice, the type of the variable R is not specified. R can take any value valid in MATLAB, it can be character, integer, floating point number, string, or even an empty value (if the user presses enter without entering any value).




Powered by Blogger.