<< Chapter < Page | Chapter >> Page > |
Any result you wish to keep for a while may be assigned to a variable
other than:
ans
A semicolon (;) at the end of the line suppresses printing of the result, as when we calculated in the next-to-last line just shown. This feature is especially useful when writing MATLAB programs where intermediate results are notof interest and when working with large matrices.
MATLAB supports the dynamic creation of variables. You can create
your own variables by just assigning a value to a variable. For example, type. Then the real variablecontains the value. Variable names
must start with an alphabetical character and be less than nineteen characterslong. If you type, the contentis replaced by the value.
Some commands allow you to keep track of all the variables that you havealready created in your session. Typeorto get the list and names
of the variables currently in memory (gives more information than).
To clear all the variables, type in. To clear a single variable (or several)
from the list, follow the commandby the name of the variable you want
to delete or by a list of variable names separated by spaces. Try it now.
clear
MATLAB is case sensitive. In other words,
and
are two different variables. You can control the case sensitivity of MATLAB by entering the command, which toggles the sensitivity. The commandon enforces case sensitivity, andcancels it.
casesen off
If one line is not enough to enter your command, then finish the first line with two dots . . and continue on the next line. You can enter more than one command per line by separating them with commas if you want the result displayed or with semicolons if you do not want the result displayed. For example, type
to first compute,, andand then to print
and
.
sin(theta)
Notification Switch
Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?