GT AE 6382 - Vectors and Matrices

Unformatted text preview:

Vectors and Matrices Learning Objectives Understand the nature of matrices Understand how to manipulate matrices in Matlab AE6382 Design Computing Lecture Basic vector matrix concepts Creating arrays and matrices Accessing matrix components Manipulating matrices Matrix functions Solving simultaneous equations 1 Fall 2006 Using Matlab with Arrays and Matrices Matlab s origins are in the early efforts to develop fast and efficient programs for handling linear equations Operations with arrays vectors and matrices are needed Only the most computationally efficient routines are used Matlab is very C like but adds a number of operators and extends its syntax to handle a range of array vector and matrix operations Matlab s fundamental data structure is the array and vectors and matrices follow easily BUT to see some of the power of Matlab for engineering applications we ll have to dig a bit more deeply into some of the underlying math no this is not going to turn into a math class but it s often hard to avoid math in engineering AE6382 Design Computing 2 Fall 2006 Basic Concepts Scalars magnitude only x mass color 13 451 Vectors magnitude r ANDrdirection force 12 74 i 5 234 j r r r r r r H a1i1 a2 i2 a3i3 a4i4 L an in Arrays can be 2D or higher dimension a11 a12 a13 a14 A a a a a 22 23 24 21 a31 a32 a33 a34 R rijk AE6382 Design Computing 3 Fall 2006 Matlab Can Handle This Scalars whos Name a density mass resistance s stress Size 1x1 1x1 1x1 1x1 1x1 1x1 Bytes 8 8 8 8 8 8 Class double double double double double double array array array array array array Vectors force 12 3 5 67 force 12 3000 5 6700 hvec 1 5 3 4 0 hvec 1 5 3 4 0 Arrays coef 1 2 4 3 coef 1 2 4 3 AE6382 Design Computing 4 Fall 2006 Basic Array Operations Addition subtraction C A B where cij aij bij C A B B A 1 2 4 1 4 3 3 6 C 3 3 7 9 Multiplication division C A B where cij aij bij C A B C A B C C 4 2 0 2500 2 0000 12 18 1 3333 0 5000 Exponentiation C A 4 where cij aij4 C A 2 C 1 4 16 9 AE6382 Design Computing 5 Fall 2006 Notes on Array Operations Arithmetic operations on arrays are just like the same operations for scalars but they are carried out on an element by element basis the dot before the operator indicates an array operator it is needed only if the meaning cannot be automatically inferred A 1 2 3 4 5 2 A ans 2 4 6 8 10 2 A ans 2 4 6 8 10 B 2 4 6 8 10 A B ans 2 8 18 32 50 A B Error using Inner matrix dimensions must agree when combining arrays make sure they all have the same dimensions applies to vectors 2D arrays multi dimensional arrays AE6382 Design Computing 6 Fall 2006 More Notes on Array Operations Most Matlab functions will work equally well with both scalars and arrays of any dimension A 1 2 3 4 5 sin A ans 0 8415 0 9093 0 1411 0 7568 0 9589 1 4142 1 7321 2 0000 2 2361 sqrt A ans 1 0000 Use brackets to construct arrays Use colon notation e g A 2 or f 3 11 to index AE6382 Design Computing 7 Fall 2006 Array Constructors Arrays are often read into Matlab from files or entered by the user But building arrays from scratch can be tedious Explicit g 1 1 g 2 3 g 3 4 g 1 3 4 Using Matlab array constructors A ones 2 3 A 1 1 1 1 1 1 B 3 ones 1 5 B 3 3 3 3 3 C zeros 2 3 C AE6382 Design Computing 0 0 0 0 0 0 8 Fall 2006 Let s Build Some Arrays What will these produce A 3 eye 2 2 A 3 0 0 3 D magic 5 B diag 1 2 3 4 diag D B diag diag D 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4 C diag 1 2 1 1 Z magic 3 zeros 3 2 ones 3 1 4 ones 2 4 eye 2 2 Z 3 mess 10 rand 4 5 messy 10 randn 4 5 C 0 1 0 0 0 0 2 0 0 0 0 1 0 0 0 0 test 1 3 ones 2 3 diag A ans 3 3 AE6382 Design Computing 9 Fall 2006 Vectors and Matrices We ve referred to vectors and matrices frequently but exactly what are we talking about what is a matrix is it different from an array ANSWER vectors and matrices are arrays with an attitude that is they look just like an array and they are arrays but they live by a very different set of rules Vectors r r f b r 3 f r r f gg r r s r r h r r a b AE6382 Design Computing Can you explain what if anything results from these operations with vectors 10 Fall 2006 Why Matrices A matrix is an array that obeys a different set of rules addition subtraction are same as for arrays but multiplication division etc are DIFFERENT a matrix can be of any dimension but 2D square matrices are the most common by far A large and very useful area of mathematics deals with what is called linear algebra and matrices are an integral part of this Many advanced computational methods in engineering make extensive use of linear algebra and hence of matrices AE6382 Design Computing 11 Fall 2006 A Simple Example A set of simultaneous linear algebraic equations will often arise in engineering applications 3 x 2 y 14 x 4 y 14 How do you solve these Solve first for x in terms of y substitute in second and solve for y use this in first to find x Use Cramer s Rule Other Let s try a more abstract notation 3 2 x 14 OR 1 4 y 14 AE6382 Design Computing 12 C z b Fall 2006 A Simple Example cont d What do we mean by the for this form 3 2 x 3x 2 y C z 1 4 y x 4 y Note that the column matrix z is multiplied times the first row of C on an element by element basis and the results are summed to get the first row of the answer Ditto for the second row This is NOT array multiplication it is matrix multiplication For two 2D matrices in general A B C where NOTE the number of columns in A must be equal to the number of rows in B N in this example N cij aik bkj k 1 AE6382 Design Computing 13 Fall 2006 A Few Notes on Matrices Matlab handles matrix multiplication with the symbol NOTE this is NOT array multiplication …


View Full Document

GT AE 6382 - Vectors and Matrices

Download Vectors and Matrices
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Vectors and Matrices and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Vectors and Matrices 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?