MATLAB Assignment B hints:

advertisement
MATLAB Assignment B hints:
Lab B focuses on Chapters 2 and 3 of the MATLAB
textbook, working with vectors and matrices.
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.
#2: Creating a row vector by just typing in the numbers (pp36-37)
#8 (colon or linspace): Creating a row vector with equally-spaced elements using colon
notation (p37) or linspace (p38). Here linspace is preferred since you are given the
number of elements rather than the increment (Delta-x).
#36: You should use the colon notation to create the matrix. See pp44-45 to refer to
specific rows/columns of the given matrix.
#43: See pp40-41 for the ones, zeros, and eye (identity matrix) commands. These can be
put in "rows" or "columns" together 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, B, and C using the commands and
put these in rows or columns instead.
=============================
Chapter 3 of the MATLAB textbook covers operations on vectors and matrices,
including element-by-element operations.
#3 (element by element operations): pp72-74 of the MATLAB textbook. 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.
#9 (application of element by element operations): You should find the magnitude of
the vector using the second method described in problem 8 (with an element by element
operation. If you need a hint, ask yourself what it is that you are doing to the elements of
the vector in the formula).
#20 (dot): The steps are outlined in the problem. You should only use the arccosine
formula, which is explained in problem 19.
#34: (solving equations with matrices): Remind yourself how to write a system of
equations in matrix form (p68) and use inverses (p69) or left-division of matrices (p70).
There is a great example on pp71-72. NOTE that this example does NOT use
element-by-element operations!
Download