% makeAvi(filename,rotations)
%
% makes an avi of the current 3d figure being rotated 360 degrees
% rotations times. If no filename is specified, uses output.avi
function makeAvi(filename,rotations)
  if nargin<1
    filename='output.avi';
  end
  if nargin<2
    rotations=1;
  end

  % fix aspect ratio
  axis vis3d;

  % create file
  movie=avifile(filename,'fps',30,'compression','none');

  for i=1:(360*rotations)
    view([i 10]);
    drawnow;
    disp(sprintf('%d',i));

    movie=addframe(movie, gcf);
  end

  movie=close(movie);
end