Skip to main content

Matrix and Vector Tutorial



  • Note that this tutorial requires the latest version of EngineeringPaper.xyz, if you see the green arrow new version icon on the top toolbar, you'll need to close all of your open EngineeringPaper.xyz tabs to load the updated version (refreshing the page is not sufficient). Once the new version icon disappears, you're at the latest version.


    Defining Matrices and Vectors

    In addition scalar values, EngineeringPaper.xyz supports matrices and vectors. Note that in EngineeringPaper.xyz, vectors are not different than matrices and are represented by matrices with either a single row or column. A matrix can be created either using the "Matrices" tab on the virtual keyboard or by typing [m,n] and than hitting enter, where m is the number of rows and n is the number of columns. For example, type [2,3] and than hit Enter to create a matrix with 2 rows and 3 columns.


    Any valid expression can be entered into a matrix, including numbers with units. See the following example:





  • Like scalar quantities, the units of the matrix output can be specified by placing the desired units after the equals sign of the query statement (note that this only works if all of the elements of the matrix have the same units).





  • It can be tedious to define the units for every element of a large matrix. In these cases, a scalar multiplied times the matrix can be used to set the units:





  • Matrix Multiplication

    EngineeringPaper.xyz has two different multiplication operators. The typical scalar multiplication operator can be typed using the * key and the matrix multiplication operator can be typed using the @ key (or by typing Ctrl-*). In the actual mathematical expression, the scalar multiplication operator is represented by a dot and the matrix multiplication operator is represented by an x. From the virtual keyboard, the * button represents scalar multiplication and the x button on the "Matrices" tab of the keyboard represents matrix multiplication. The scalar multiplication operator should be used for all multiplication except when both the right hand and left hand sides of the multiplication are matrices or vectors. In many cases, the correct result will be obtained even when the wrong multiplication operator is used. However, to avoid errors or surprising results, it's best to use the correct multiplication operator for the situation. Below is an example of the different multiplication operators in use:





  • Like other expressions, matrices can be assigned to variables and used in expressions as shown below:







  • Note that the above example is a case where it is important to used the matrix multiplication operator. Unintended results will be obtained if the scalar multiplication operator is used, as shown below:





  • Dot Product and Cross Product

    The dot product can be computed for two vectors of the same size using the dot function as shown below:





  • or using row vectors:





  • The matrix multiplication operator will automatically calculate a cross product if both vectors are either 3x1 or 1x3 (note that the shape of the result vector matches the shape of the input vectors):







  • Transpose

    The transpose of a matrix can be obtained using the apostrophe keyboard shortcut or using the virtual keyboard:





  • The transpose function can be used as well:





  • Euclidean Norm of a Matrix

    The magnitude of a matrix can be calculated using the norm function or using the matrix norm notation ||v||:







  • Matrix Inverse and Determinant

    The inverse or determinant of a matrix can be calculated using the inv and det functions. Additionally, the inverse can be obtained by using a exponent of -1:









  • Indexing a Matrix

    A subscript with two numbers separated by a comma can be used to access the elements of a matrix. Use the underscore keyboard shortcut to create a subscript. Note that array indexing starts with 1. The first index represents the row and the second index represents the column.









  • The indices may be any valid mathematical expression as long as it evaluates to an integer value:







  • Note that since vectors are themselves matrices, two subscripts are required to index a vector:





  • Equation Solving with Matrix Equations

    The symbolic and numerical equation solvers work with matrices as well. The following example shows how to solve for the Eigenvalues of a matrix:



  • System =
    Solution =
    Selected Solution:
    Solve for: