Practical 2: Variables, Script M-files and Graphing
Variables
Naming variables
The following commands illustrate the order of priority when evaluating expressions.
A love-struck engineer specialising in planning the foundations of a building wrote the following code to calculate the area of a rectangle. > Determine what each variable represents and then rename the variables to write the new code in MATLAB with meaningful variable names. dinner = 4 nice = 7 roses = dinner*nice |
Some important rules for variable names are:
The preferred naming convention is to capitalise the start of each new word, as in ThisIsALongVariable however some people prefer to separate words with underscores, as in this_is_a_long_variable. |