Comments
Comments
Whenever we develop programs, the correctness of the program (whether it produces the "right" results)
is a very important concern, but it is not the only concern. Other important factors include efficiency
and programming style. Efficiency refers to whether the program runs in a reasonable amount of time and
uses a reasonable amount of memory. Programming style includes such things as clear and understandable
algorithms, good organization, descriptive variable names, effective use of whitespace, and appropriate
documentation (comments). Comments are an important and effective way of making our programs easier to
read and understand (as well as debug). Comments are meant for humans to read; in fact, Matlab ignores
all comments when it executes code. Comments in Matlab begin with a percent sign ( % ) and continue
to the end of the line:
% this is a comment
METERS_PER_INCH = 0.0254 % conversion constant for inches to meters
heightInInches = 71 % this is also a comment
% convert height to meters
heightInMeters = heightInInches * METERS_PER_INCH
Use comments liberally in your code to help you, your collaborator and your instructor understand what your code does and how it does it.