Review from Day 1:

 

 

 

 

 

 

 

 

 

Hints:

  1. If you just execute another plot command, the new plot will simply replace the old plot. You need to type hold on before any subsequent plots. After hold on, everything else, including the scale, remains the same in the figure.
  2. The general statement to plot a circle of radius r centered at y0,x0 is:                       plot(y0 + sin(t) * r, x0 + cos(t) * r);
  3. When in doubt, use help. For example, help sum gives you some pointers on how to use the function sum.

 

Exercises:

 

  1. Draw 3 concentric circles at (0,0), one of radius 1, one of radius 0.5 and one of radius 0.25;
  2. On a different graph draw 4 circles of radius 0.5, at (-0.25, -0.25), (-0.25, 0.25), (0.25, -0.25) and (0.25, 0.25). Hint: to change the x and y limits of the graph, use axis([xmin xmax ymin ymax]). In this case, try axis([-2 2 -2 2]) before using hold.
  3. Generate a random 4x4 matrix using a = rand(4,4); Use the sum function to calculate the sum of each column, the sum of each row and the total sum of the matrix. There are several ways to do this one.
  4. The general statement to plot an ellipse is plot(y0 + sin(t) * ry, x0 + cos(t) * rx); Plot 2 ellipses centered at (2,2). One with the vertical radius twice the horizontal radius and the other with horizontal radius twice the vertical radius.