gibson:teaching:spring-2016:math445:lab2

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.

2. Assign the transpose of u to the variable w.

3. Change the third element of w to 10.

4. Assign a column vector with the elements 7, 1, -2, 3 to the variable z.

5. Add w and z. Does the result make sense?

6. Add u and z. Does the result make sense?

7. Create a vector of the even integers between 2 and 14, inclusive.

8. Create a vector of the odd integers between 7 and 19, inclusive.

9. What is the sum of every third number between 3 and 27, inclusive?

10. What is the sum of the integers between 1 and 100, inclusive?

11. Make x a vector from 0 to in increments of 0.02.

12. Run `plot(x, sin(x))`

. What happens?

13. Run `plot(x, sin(x), 'r–')`

. What happens?

14. Run

plot(x, sin(x), 'r--', x, cos(x), 'm-') xlabel('x') legend('sin x', 'cos x')

What happens?

15. Make a plot of the polynomial over the range . In the same plot, draw a line along the axis. (Hint: in Matlab create a zero vector of the same length as your vector with `y=0*x`

, then plot versus along with versus .) Using this plot, estimate the zeros of the polynomial, i.e. the values of for which .

gibson/teaching/spring-2016/math445/lab2.txt · Last modified: 2016/02/02 08:35 by gibson