Page History: Matrices
Compare Page Revisions
Page Revision: 2009/10/04 20:44
There are few ways to insert matrix (matrices). From the menu:
Insert=>Matrix, keybord shortcut
CTRL+M, from the Matrices palette (Matrix 3x3), inserting the function
mat(. You will get the 3x3 template, or the dialog box to insert 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 matrix 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 horizontal line will appear. With the left mouse button (mouse pointer will change the appearance) drag and correct the dimensions. You can do that even if the placeholders are not empty,
Let us now fil in the placeholder like in the following 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 undefined 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 matrix
A symbolically (operator →) or numerically (operator = ). Note the difference:
Also, the individual matrix element could be presented with the function
el. Press
el(A, or
A[. You will see
Now, you can insert single integer (vector) or two integers (matrix) to asign vector or matrix elements. Here (matrix) press 3,1→ or 3,1= . The value of
A in the third row and first column will appear (the minimal row and column index is 1).
SMath will consider
column matrix as
vectors. Vector elements need only one index. Here is the example (row matrices 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,
z5 5:=2Besides 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: