Navigation
Main Page
Random Page
Create a new Page
All Pages
Categories
Administration
File Management
Login/Logout
Language Selection
Your Profile
Create Account
Quick Search
Advanced Search »
Back
History
Matrices
==[anchor|#Editing]Editing== 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. [image||{UP}Matrices/mat1.png] 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, [image||{UP}Matrices/mat2.png] 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) [image||{UP}Matrices/mat3.png] ==[anchor|#Usage_Symbolic_vs_Numeric]Usage: <esc> </esc>Symbolic vs. Numeric== If we assign the values to variables ''a'' and ''b'' before the matrix definition, the result would be: [image||{UP}Matrices/mat4.png] We can present the result of matrix ''A'' symbolically (operator →) or numerically (operator = ). Note the difference: [image||{UP}Matrices/mat5.png] ==[anchor|#Extracting_Elements]Extracting Elements== Also, the individual matrix element could be presented with the function '''el'''. Press '''el(A,''' or '''A['''. You will see [image||{UP}Matrices/mat13.png] ==[anchor|#Assigning_Values_to_Elements]Assigning Values to Elements== 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). [image||{UP}Matrices/mat6.png] ==[anchor|#Vectors]Vectors== 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) [image||{UP}Matrices/mat7.png] ==[anchor|#Advanced]Advanced== It should be noted that elements of a matrix could be of different data type (numeric, text, units). Here are few simple examples demonstrating this feature. [image||{UP}Matrices/matrixel.png] Note the using of function '''row''' and '''col''' to extract a single row or single column. SMath also supports nested matrices, i.e. the matrix element could also be a matrix. See the next example. [image||{UP}Matrices/mat8.png] The individual elements are presented in the same way as before. [image||{UP}Matrices/mat10.png] Matrices in SMath are dynamic arrays and they can change their dimensions. For instance '''matrix''' function gives a matrix filled with zeros. See how you can do the same by assigning the zero value to the element z<sub>3 4</sub>. [image||{UP}Matrices/mat9.png] Try to put now, say, '''z<sub>5 5</sub>:=2''' Besides the matrix/vector variables, there are also matrix/vector functions. [image||{UP}Matrices/mat11.png] 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: [image||{UP}Matrices/mat12.png] You can initialize an empty matrix with a fixed dimension using the matrix(rows,cols) and setting one of the two arguments to 0. [image||{UP}Matrices/mat14.png]
ScrewTurn Wiki
version 2.0.37. Some of the icons created by
FamFamFam
.