title: Matlab for loop animations
body: <p>I'm trying to animate the graph of a function but I cant get the program to graph the correct points. I want to plot points between time 0 and 10 and animate this graph. How do I get the plot as a function  of time?</p>
  
  <pre><code>clear;
  w = 2*pi; 
  t = 0:.01:10;
  y = sin(w*t); 
  x = cos(w*t);
  
  
  for  j=1:10
    plot(x(6*j),y(6*j),'*');
    axis square;
    grid on;
    F(j) = getframe;
  
   end 
   movie(F,1,1);
  </code></pre>
  
  <p>I refined the code to:</p>
  
  <pre><code>clear;
   w = 2*pi; 
  
  
  
   for  j=2:11
   t=j-1;
   y = sin(w*t); 
   x = cos(w*t);
    plot(x(t),y(t),'*');
    axis square;
    grid on;
    F(j) = getframe;
  
   end 
   movie(F);
  </code></pre>
  
  <p>This should do what I'm trying however now I'm getting an "Index exceeds matrix dimension." How can I solve this?</p>