SPRING 2016 MATH 151 LAB B HINTS PENG WEI 1. Chapter #2 Chapter 2 focuses on creating vectors (lists of numbers) and matrices (semicolons between lists to start new rows), creating equally-partitioned rows using the colon notation or linspace, and creating new vectors and matrices using subsets of the rows and columns of a given matrix. • Chapter 2 #5: Define the variables as done in Chapter 1, then create a column vector either by just typing in the values with semicolons or ENTER between them (see pp36 − 37) OR by transposing a row vector (pp41 − 42). • Chapter 2 #7: Creating a row vector with equally-spaced elements using colon notation (p37) or linspace (p38). Here colon notation is preferred since you are given the increment rather than the number of elements. NOTE: Do not just enter the elements individually! • Chapter 2 #33: You should enter the rows of the matrix A using : notation, then refer to p44 − 45 to use the colon notation to refer to specific parts of the matrix. • Chapter 2 #39: Refer to #5 in MATLAB Procedures for turning in work by hand. • Chapter 2 #44: (ones, zeros): Define A using the ones command (pp40 − 41) These can be put in “rows” or “columns” together with zeros matrices to make new matrices, provided the dimensions match. See Sample Problem 2-1 (the “different solution” at the top of p51) for an example, although in this problem, you will define A using the commands and put it in rows or columns instead. 2. Chapter #3 Chapter 3 of Gilat covers operations on vectors and matrices, including element-byelement operations. • Chapter 3 #1 (element by element operations): See pp72−74 of Gilat. In particular, when you wish to multiply or divide the elements of one vector/matrix by the corresponding elements of another vector/matrix, or when you want to raise all the elements to a power, you MUST place a “.” in front of the *, /, or ∧ symbol. Refer to the last two examples on p74. • Chapter 3 #19 (dot): Define vectors r1 and r2, then follow the steps outlined in the problem. 1 2 PENG WEI • Chapter 3 #23: Again, the steps are outlined in the problem (do it 3 times-one for each new n value). Instead of comparing to ln(10), compare to the value obtained using symsum (defining n as a symbolic variable first. See the second example of the HELP for syntax). • Chapter 3 #27: Application of element-by-element operations, done as in #1. • Chapter 3 #35 (solving equations with matrices): First write a system of equations in matrix form (p68) then use inverses (p69) or left-division of matrices (p70). There is a great example on pp71 − 72. NOTE that this example does NOT use elementby-element operations!