title: Problems with movie file creation in MATLAB
body: <p>I attempt to create a movie by looping through frames in MATLAB.</p>
  
  <p>Refering to mathworks.com documentation at <a href="http://www.mathworks.com/help/techdoc/ref/movie.html" rel="nofollow noreferrer">http://www.mathworks.com/help/techdoc/ref/movie.html</a>, I've managed to animate a plot. However, issues arise when I attempt to save the movie in an avi file.</p>
  
  <p>Both the <code>avifile</code> and <code>VideoWriter</code> methods from <a href="https://stackoverflow.com/a/8038540/818608">https://stackoverflow.com/a/8038540/818608</a>, resulted in the same errors.</p>
  
  <p>Although the animation runs fine, the saved movie consists of only one fixed frame, and at times, the screen capture includes an overlay of my background web browser.</p>
  
  <p>Thank you in advance.</p>
  
  <p>Below is the code I used, and the frame that's frozen on the avi is linked below.</p>
  
  <pre><code>Z = peaks; surf(Z); 
  axis tight
  set(gca,'nextplot','replacechildren');
  
  vid = VideoWriter('myPeaks2.avi');
  vid.Quality = 100;
  vid.FrameRate = 15;
  open(vid);
  for k = 1:20 
      surf(sin(2*pi*k/20)*Z,Z)
      writeVideo(vid, getframe(gcf));
  end
  close(vid);
  
  winopen('myPeaks2.avi')
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Ipk7t.jpg" alt="The frame that&#39;s frozen on the avi is linked below"></p>