Mathematics 110 University of Victoria Fall 2013 MatLab Project # 1 Due IN TUTORIAL Wednesday October 30 Name ID V00 Section A0 Tutorial T0 Instructions: After completing this project, copy and paste your Matlab work into a word processing application (e.g. Microsoft Word), insert your figures/plots in the appropriate places and print out your work. Turn in a printout of your work with this cover page stabled to the front. MATLAB software can be accessed at UVic computing centers, http://www.sfg.uvic.ca/facilities.php To run MATLAB, go to Start / All programs / Matlab. See Demo to get used to the basic coding in Matlab. Matlab is a programming environment built for doing matrix arithmetic. A lot can be learned from trial and error, and experimentation is encouraged. Further, please read the short Matlab introduction kindly provided by Caltech http://web.gps.caltech. edu/classes/ge11d/doc/matlab_resource_seminar.pdf Additional documentation can be found at the Matlab website http://www.mathworks. com/help/techdoc/index.html?/access/helpdesk/help/techdoc/\math/f4-983672. html= See Matrices in the MATLAB Environment and Systems of Linear Equations Quick Tips: You can suppress Matlab output by adding a ; to the end of your Matlab command. (This is useful for Matlab commands executed in loops). You can save plots/figures from the figure s dialog by selecting Save as and then choosing png or jpg in the file-types dropdown. 1
Problem #1: When given as input a matrix A the Matlab command rref produces the Reduced Row Echelon Form of this matrix or augmented matrix. Familiarize yourself with the syntax and the use of rref by handling some easy examples for which you know the answer or can find it by hand. For each of the following augmented matrices, use rref to determine whether the solution of the corresponding system is a point, line, plane, or does not exist. Note, you do not need to write the solution, just whether it is a point, line, plane, etc. 1. [A b]= 1 1 1 0 3 1 0 0 2 4 5 0 2. [A b]= 1 1 1 1 3 1 0 3 2 4 5 2 3. [A b]= 1 1 1 1 3 1 0 4 2 4 5 2 Include: In your printout, include all Matlab input and output involved in this problem. 2
Problem #2: The matrix R = [ 0.999847695 ] 0.017452406 0.017452406 0.999847695 rotates a vectors counter clockwise by 1. That is for a column vector v, Rv is v rotated by 1. For the vector e = [ ] 1 compute the following: 0 e rotated counter clockwise by 2 e rotated counter clockwise by 7 e rotated counter clockwise by 48 Now that you are familiar with rotating things, let s do something more interesting. Construct a 2 360 matrix C whose columns form boundary points of the unit circle. That is C = [v 1 v 2 v 3 v 360 ] where v 1 is e rotated by 1, v 2 is e rotated by 2 and v i is e rotated by i. (Hint: you may want to initialize C to a 2 360 zero matrix with C = zeros(2,360); and then use a for loop to populate the entries of C. Extra information on for loops in Matlab can be found http://www.cyclismo.org/tutorial/ matlab/control.html). Plot your circle by using the first row of C as the x coordinates and the second row of C as the y coordinates. This can be done with the command plot(c(1,:), C(2,:)) Include: In your printout, include all Matlab input and output used to calculate e rotated by 2, 7, 48. Further, include the code used to generate the matrix C and the plot of C. You do not need to include the values of C in your printout. 3
Problem #3: Create a matrix S = [ 0 1 1 0 ] 0 0 0 1 1 0 whose columns form the vertices of the unit square (the 1 1 square with lower-left corner at the origin) listed in counter-clockwise order with the origin listed twice. Plotting with row one of S as the x coordinates and row two of S as the y coordinates will produce a square. Using S and the matrix R from Problem #2, create the matrices X and Y where X s columns are the vertices of the unit square rotated by 33 and Y s columns are the vertices of the unit square rotated by 104. Graph all three squares on the same plot. (You can do this with plot(s(1,:), S(2,:), X(1,:), X(2,:), Y(1,:), Y(2,:))) Include: In your printout, include all Matlab input and output involved in this problem as well as your plot with three squares. 4
Bonus: (Optional and not for marks, but you could put a smile on your markers face). Use your imagination and creativity to come up with a matrix A so that plot(a(1,:), A(2,:)) draws an outline of your choosing. Use Matlab to create a plot of your outline, your outline stretched horizontally by a factor of two and your outline stretched horizontally by a factor of two and then rotated counter clockwise by 45. 5