Page 35 - Computational Colour Science Using MATLAB
P. 35

22               A SHORT INTRODUCTION TO MATLAB

                    w = linspace(400,700,31);

               would generate a 31-dimensional vector containing the values 400, 410, 420, ...,
               700 evenly spaced between 400 and 700. In order to discover the operation of
               other functions use the help command such as

                    >>help size
                    SIZE Size of matrix.
                    D = SIZE(X), for M-by-N matrix X, returns the two-element
                    row vector D = [M, N] containing the number of rows
                    and columns in the matrix. For N-D arrays, SIZE(X) returns
                    a 1-by-N vector of dimension lengths. Trailing singleton
                    dimensions are ignored.
                    [M,N] = SIZE(X) returns the number of rows and columns in
                    separate output variables. [M1,M2,M3,...,MN] = SIZE(X)
                    returns the length of the first N dimensions of X.
                    M = SIZE(X,DIM) returns the length of the dimension
                    specified by the scalar DIM. For example, SIZE(X,1) returns
                    the number of rows.
                    See also LENGTH, NDIMS.

               When entering matrices in MATLAB names must begin with a letter, contain
               only letters or digits, and although they may be entered of any length, MATLAB
               only retains the first 19 characters. During a MATLAB session the values of all
               defined variables are stored in the workspace. The user may save the current list
               of variables and their associated values using the save command. The command
               save myfile.mat, for example, will save the workspace as a special MATLAB
               file and this may be recovered during a new session using the load command.
                 The command clear will remove all user-defined variables from the workspace.
               The format of displayed numbers during a session can be changed using the
               format command. Finally, it is important to note that MATLAB is case sensitive.



               3.2 Computing the transpose and inverse of matrices

               A matrix may be easily transposed in MATLAB using the ’ operator. Thus, if x
               is a 3 1 column matrix, then the command

                    x = x’;

               will convert x into a 1 3 row matrix.
                 The inv operator has already been introduced for computing the inverse of a
               matrix when solving a pair of simultaneous equations. The inv command can
   30   31   32   33   34   35   36   37   38   39   40