1.2.1 Creating a Matrix
To create a new matrix and store it in a variable so that it you can
refer to it later, type the command
octave:1> A = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ]
Octave will respond by printing the matrix in neatly aligned columns.
Ending a command with a semicolon tells Octave to not print the result
of a command. For example
octave:2> B = rand (3, 2);
will create a 3 row, 2 column matrix with each element set to a random
value between zero and one.
To display the value of any variable, simply type the name of the
variable. For example, to display the value stored in the matrix B,
type the command
octave:3> B
1.2.2 Matrix Arithmetic
Octave has a convenient operator notation for performing matrix
arithmetic. For example, to multiply the matrix a by a scalar value,
type the command
octave:4> 2 * A
To multiply the two matrices a and b, type the command
octave:5> A * B
and to form the matrix product transpose (A) * A, type the command
octave:6> A' * A
1.2.3 Solving Linear Equations
To solve the set of linear equations Ax = b, use the left division
operator, ‘\’:
octave:7> A \ b
This is conceptually equivalent to inv (a) * b, but avoids computing
the inverse of a matrix directly.
If the coefficient matrix is [...]