Skip to main content
New Sheet Tutorial

Matrix and Vector Tutorial



  • 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 symbols. The typical scalar multiplication symbol can be typed using the * key and the matrix multiplication symbol can be typed using the @ key (or by typing Ctrl-*). In the actual mathematical expression, the scalar multiplication symbol is represented by a dot and the matrix multiplication symbol 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. In all cases, except for the cross product case described below, it is safe to use either multiplication symbol for scalar or matrix multiplication. However, using the matrix multiplication symbol for all multiplication between two matrices may be helpful to make the intent more clear as in the following examples:





  • Like other expressions, matrices can be assigned to variables and used in expressions 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 symbol 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 matrix 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:





  • Using Summation and Product Notation

    Summation or product notation, along with the numrows and numcols functions, may be used to loop over matrices. For example, the following calculates the sum of the values in the second row of the matrix :







  • 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:


  • The result value can then be used on other expressions as shown below: