title: MATLAB getframe captures whatever is on screen
body: <p>I am trying to create a movie from my MATLAB plot. When I call getframe, it "usually" captures the plot image, but sometimes if there is something else active on the screen (which is normal if I continue to use the computer) it captures whatever window is active. Is there another way to grab the image of the active figure?</p>
  
  <p>e.g.</p>
  
  <pre><code>fig = figure;
  aviobj = avifile('sample.avi','compression','None');
  for i=1:t
      clf(fig);
      plot(...); % some arbitrary plotting
      hold on;
      plot(...); % some other arbitrary plotting
      axis([0 50 0 50]);
      aviobj = addframe(aviobj, getframe(fig));
  end
  aviobj = close(aviobj);
  </code></pre>