Page 15 - Basics of MATLAB and Beyond
P. 15

1.3   Matrices
                               The basic object that matlab deals with is a matrix. A matrix is an
                               array of numbers. For example the following are matrices:

                                                                                 
                                                                              i
                                          12    3   9
                                                                              −i  
                                      −1200    0  1e6   ,  12345         ,       , 42.
                                                                               i 
                                         0.1   pi  1/3
                                                                               −i
                               The size of a matrix is the number of rows by the number of columns.
                               The first matrix is a 3×3 matrix. The (2,3)-element is one million—1e6
                                              6
                               stands for 1 × 10 —and the (3,2)-element is pi = π =3.14159 ...  .
                               The second matrix is a row-vector, the third matrix is a column-vector
                               containing the number i, which is a pre-defined matlab variable equal
                               to the square root of −1. The last matrix is a 1 × 1 matrix, also called
                               a scalar.

                               1.4   Variables
                               Variables in matlab are named objects that are assigned using the
                               equals sign  = . They are limited to 31 characters and can contain
                               upper and lowercase letters, any number of ‘_’ characters, and numer-
                               als. They may not start with a numeral. matlab is case sensitive: A
                               and a are different variables. The following are valid matlab variable
                               assignments:
                               a=1
                               speed = 1500
                               BeamFormerOutput_Type1 = v*Q*v’
                               name = ’John Smith’
                               These are invalid assignments:
                               2for1 = ’yes’
                               first one = 1
                                  To assign a variable without getting an echo from matlab end the
                               assignment with a semi-colon ;. Try typing the following:
                               a=2
                               b=3;
                               c = a+b;
                               d = c/2;
                               d
                               who
                               whos
                               clear
                               who



                               c   2000 by CRC Press LLC
   10   11   12   13   14   15   16   17   18   19   20