Page History: Matrices
Compare Page Revisions
Page Revision: 2009/09/27 02:03
There are few ways to insert matrix (matrices). From the manu: Insert=>Matrix, keybort shortcut CTRL+M, from the Matrices pallete (Matrix 3x3), inserting the function mat(. You get the 3x3 template or the dialog box to isert the number of rows and columns. Let as assign to a variable name A, matrix with dimensions 3(rows)x3(columns). For instance, press: A: and then CTRL+M. The matrice template with 3x3 empty place holders will appear.
If you change your mind about dimensions you can always change the matrix dimensions. Just click inside the matrix on the right lower corner, The black square with a vertical and horizolntal line will appear. With the left mouse button (mouse pointer will change the appearence) drag and correct the dimmensions. You can do that even if the placeholders are not empty,
Let us now fil the placeholder like in the folowing picture. If we point the matrix with the mouse, the tooltip will appear. This is the the symbolic presentation of matrix. As you could see, real numbers are presented as fractions and there are also two udefined variables (a and b, without numerical values)
If we assign the values to variables a and b before the matrix definition, the result would be:
We can present the result of matrice A symbolicaly (operator ->) or numericaly (operator = ). Note the difference:
Also, the individual matrix element could be presnted with the function el. Press el(A, or A[. You will see
After that press 3,1-> or 3,1= . The value of A in the third row and first column will appear.
SMath will consider column matrix as vectors. Vector elements need only one index. Here is the example (row matrix still need two index, with the 1 as the first one)
SMath also supports nested matrices, i.e. the matrix element could also be a matrix. See the next example.
The individual elements are presented in the sam way as before.
Matrices in SMath are dynamic arrays and they can change their dimensions. For instance matrix function gives a matrice filled with zeros. See how you can do the same by assigning the zero value to the element z[3 4.
Try to put now, say, z[5,5=2
Besides the matrix/vector variables, there are also matrix/vector functions.
Function f have a single argument and it returns a three element vector. The argument can be scalar,vector or matrix. Try it. Function ff expects two element vector, and function F expects two arguments and returns 2x2 matrix. Play with them.
When dealing with matrices, although there are many matrix/vector operators and functions, sooner or later there will loops be involved. Most often the single, double or nested for loops are used. See this simple example