KAAP417/KAAP617 Introduction to vectors and matrices Vector = 1 dimensional array. A vector can be a “row vector” or a “column vector”. Used to represent quantities such as position, velocity, acceleration, force, velocity, in 2D or 3D world, and to represent torque, angle, angular velocity, angular acceleration, and torque in 3D. (In 2D, you don’t need vectors for angles or torques.) 0.528 Example: x=[-1 5 2], a=(3,2,1), 𝜃 = (−0.785) 1.047 9.7 𝑣 = [ 3.2 ] −11.2 Matrix = 2 dimensional array. Matrices are, among other things, shorthand representations of systems of linear equations. We can use matrix notation to represent and solve the system of linear which arise in biomechanical analyses. Matrix A has elements aijE, wher e i=row number and j=column number. In Labview, i and j start with 0. A matrix with m rows, n columns is “m by n”. Square matrix has equal number of rows and columns. One-by-n matrix = row vector; n-by-one matrix = column vector. Diagonal elements = aii. Example: 𝑏00 9 −2 0 𝐵 = [3 −4 1] = [𝑏10 𝑏20 0 −6 2 b00=9, b01=-2, b02=0, b10=3, etc. In Matlab, i and j start with 1. Example: 𝑎11 7 −1 5 𝑎 𝐴 = [ 2 −3 4] = [ 21 𝑎31 −2 8 1 a11=7, a12=-1, a13=5, a21=2, etc. 𝑏 01 𝑏11 𝑏21 𝑏02 𝑏12 ] 𝑏22 𝑎12 𝑎22 𝑎32 𝑎13 𝑎23 ] 𝑎33 A 3x3 matrix is a compact way of representing a linear transformation of one vector to another vector. The rules for linear transformations of vectors will be explained in class, with biomechanical examples. Example: Solving a linear system of equations. We can use a matrix and vector to represent a linear system with n equations and n unknowns. In this example, A is an n-by-n matrix and x and b are coulmn vectors of length n: 𝑨𝒙 = 𝒃 𝑥 where A is an n-by-n matrix and x and b are coulmn vectors of length n, with 𝐱 = (𝑦) . 𝑧 Example: the system of equation x-y+z = 0 2x-3y+4z = -2 -2x-y+z = 7 can be written with matrices as follows: 1 −1 1 𝑥 0 [ 2 −3 4] [𝑦] = [−2] −2 −1 1 𝑧 7 due to the rules for multiplying a matrix times a column vector to get another column vector. The matrix equation above can be written 𝑨𝒙 = 𝒃 where 𝑥 1 −1 1 0 𝑨 = [ 2 −3 4] , 𝒙 = [𝑦] , 𝒃 = [−2] 𝑧 −2 −1 1 7 We can solve this system of 3 equations and 3 unknowns using Labview or Matlab. First define the constants A (a matrix) and b (a column vector): Example: force plate calibration. Equality of matrices Two matrices are equal if they have same dimensions and all elements are the same. Matrix arithmetic Matrix addition Add corresponding elements; matrix dimensions must match. Commutative: A+B=B+A Associative: (A+B)+C = A+(B+C) Zero matrix: all elements = 0. A + 0 = 0 + A = A Matrix subtraction: like addition. Multiplication (or division) by a scalar Multiply (or divide) each element by same scalar. Note cA = Ac . Matrix multiplication Am×n Bn×ℓ = Cm× ℓ where the subscript “m×n” indicates that matrix A has m rows and n columns, etc. The element cij, in row i, column j of the resulting matrix C, is given by cij = ai1b1j + ai2b2j + … + ainbnj = ∑ 𝑛 𝑘=1 aik bkj 1 2 5 6 ),B = ( ) , C = AB =? 3 4 7 8 Note that number of columns in A must equal the number of rows in B for matrix multiplication (AB) to work. 1 0 Identity matrix: 𝐼2 = ( ). AI = IA = A . 0 1 Example: 𝐴 = ( Matrix multiplication is not commutative. Use Labview or Matlab to compare D=BA to C=AB. >>A=[1 2;3 4]; >>B=[5 6;7 8]; >>C=A*B, D=B*A Matrix division This is complicated. We will return to this topic later. Copyright © 2013 William C. Rose