User Tools

Site Tools


gibson:teaching:spring-2016:math445:lab2

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:spring-2016:math445:lab2 [2016/01/27 13:49]
gibson
gibson:teaching:spring-2016:math445:lab2 [2016/02/02 08:35] (current)
gibson
Line 1: Line 1:
 ====== Math 445 lab 2: vectors ====== ====== Math 445 lab 2: vectors ======
  
-Do the following in Matlab, saving your work to a file with the ''​diary''​ command. Reduce unnecessary whitespace with the ''​format compact''​ command. When you're done, edit the diary file to eliminate errors, so that your diary shows just the correct work. You can submit ​your lab either via Canvas ​or as a print out.+Do the following in Matlab, saving your work to a file with the ''​diary''​ command, and labeling each problem with a Matlab comment (e.g. ''​% problem 1''​). Reduce unnecessary whitespace with the ''​format compact''​ command. When you're done, edit the diary file to eliminate errors, so that your diary shows just the correct work. You do not need to turn in the plots of 12, 13, and 14. Just describe them verbally using Matlab comments. For 15, just provide ​your estimates of the zeroes of the polynomial. ​ Turn in your diary file on Canvas. ​
  
 1. Assign a row vector with elements 3, 4, 5, 9 to the variable u. 1. Assign a row vector with elements 3, 4, 5, 9 to the variable u.
Line 9: Line 9:
 3. Change the third element of w to 10. 3. Change the third element of w to 10.
  
-4. Create ​a vector ​of the even integers between ​and 14inclusive.+4. Assign ​column ​vector ​with the elements 7, 1, -2, 3 to the variable z.
  
-5. Create a vector of the odd integers between 7 and 19, inclusive.+5. Add w and zDoes the result make sense?
  
-6. What is the sum of every third number between 3 and 27, inclusive?+6. Add u and z. Does the result make sense?
  
-7. What is the sum of the integers between ​and 100, inclusive?+7. Create a vector ​of the even integers between ​and 14, inclusive.
  
-8. Make x a vector ​from 0 to $2\pi$ in increments ​of 0.02.+8. Create ​a vector of the odd integers between 7 and 19, inclusive.
  
-9. Run ''​plot(x,​ sin(x))''​. What happens?+9. What is the sum of every third number between 3 and 27, inclusive?
  
-10. Run ''​plot(xsin(x), '​r--'​)''​. What happens?+10. What is the sum of the integers between 1 and 100inclusive?
  
-11. Run +11. Make x a vector from 0 to $2\pi$ in increments of 0.02.
  
-<​code>​+12. Run ''​plot(x,​ sin(x))''​. What happens? 
 + 
 +13. Run ''​plot(x,​ sin(x), '​r--'​)''​. What happens? 
 + 
 +14. Run  
 + 
 +<​code ​matlab>
 plot(x, sin(x), '​r--',​ x, cos(x), '​m-'​) plot(x, sin(x), '​r--',​ x, cos(x), '​m-'​)
 xlabel('​x'​) xlabel('​x'​)
Line 32: Line 38:
  
 What happens? What happens?
 +
 +15. Make a plot of the polynomial $f(x) = x^3 -5x^2 + 2x + 3$ over the range $-1 \leq x \leq 5$. In the same plot, draw a line along the $x$ axis. (Hint: in Matlab create a zero vector of the same length as your $x$ vector with ''​y=0*x'',​ then plot $y$ versus $x$ along with $f$ versus $x$.) Using this plot, estimate the zeros of the polynomial, i.e. the values of $x$ for which $f(x) = 0$. 
  
gibson/teaching/spring-2016/math445/lab2.1453931356.txt.gz · Last modified: 2016/01/27 13:49 by gibson