A Script is nothing but, a computer program written in the language of MATLAB. It is stored in an M-file. It is saved with extension .m. We can display the contents of the script in the Command Window using the type command followed by file name without .m extension. Interpreter is a computer program which executes the statements of script step by step. The script can be executed, or run, by simply entering the name of the file (without the .m extension) in the command window. MATLAB ignores the comment lines and does not execute when we run the M-file.
For example:
Note that type command is helpful to see the contents of the script in the Command Window. For eample:
>> type radius
To run the script, the name of the le is entered at the prompt (again, without the .m) or press F5.
The simplest output function in MATLAB is disp, which is used to display the result of an expression.
For example:
In the Command Window,
In the Command Window,
fprintf() displays the values of several variables in a specified format. For example:
In the Command Window,