Illustration of script Documentation:
For illustration, the script to compute the area of a circle could be modified to have comments:
The first comment at the starting of the script explains what the script does. Then, throughout the script, comments explain various parts of the script (not generally a comment for every line, though!). The Comments don't affect what a script does; therefore the output from this script would be similar as for the earlier version.
The help command in a MATLAB works with scripts as well as with the built-in functions. The initial block of comments (defined as adjacent lines at the starting) will be displayed. For illustration, for script1b:
>> help script1b
This program evaluates the area of a circle
The reason that a blank line was inserted in the script between the first two comments is that otherwise both would have been interpreted as one adjacent comment, and both lines would have been displayed with help. The very first comment line is known as the H1 line; it is what the function look for searches through.