|
|
|
Remember to press Enter or Return after each command.
Note that the variable x has been assigned the value 3, and the variable y has been assigned the value 2, so the algebraic expression you typed was evaluated using those values, and the result has been stored in the variable ans.
In general, to see what is stored in a variable, just type its name.
Note the effect of the semicolon; use it when you do not want to see your input echoed. The computer still knows what is stored in the variable z.
There may in fact be times when you want to use the letter a to represent a real number and the letter A to represent a matrix, and MATLAB will let you do that. Remember, if you ever forget what variables are in current use, use the who command. (Or, for more information, use the whos command!)
You will make use of vector variables on many ocassions in MATLAB. A vector is just a list of numbers. To enter a vector, enclose its components in square brackets and separate them by commas or blanks. This gives you a "row vector." which displays horizontally. You can make it into a "column vector" by putting a single quote mark after it.
x = [3, -1, 4, 2]
x'
% Transpose
You can do arithmetic operations on all components of a vector at once. This is especially important when you want to plot the graph of a function.
In order to of raise all components of a vector to a power or divide or multiply one vector by another, you must use the dot operator.
Make sure you understand what is going on before continuing to the next part of the tutorial.
|
|
|
modules at math.duke.edu | Copyright CCP and the author(s), 2000 |