Up | Next | Prev | PrevTail | Tail |

Matrix expressions may appear in the right-hand side of assignment statements. If the left-hand side of the assignment, which must be a variable, has not already been declared a matrix, it is declared by default to the size of the right-hand side. The variable is then set to the value of the right-hand side.

Such an assignment may be used very conveniently to find the solution of a set of linear equations. For example, to find the solution of the following set of equations

a11*x(1) + a12*x(2) = y1

a21*x(1) + a22*x(2) = y2

a21*x(1) + a22*x(2) = y2

we simply write

x := 1/mat((a11,a12),(a21,a22))*mat((y1),(y2));

Up | Next | Prev | PrevTail | Front |