function mov = immovie(a,siz)
%IMMOVIE Make a movie of an image deck.
%	MOV = IMMOVIE(D,[M N P]) returns a movie matrix MOV created
%	from the images in the M-by-N-by-P deck D.  The movie can
%	be played using MOVIE.
%
%	Image decks are a set of images arranged row-wise in a matrix.
%	An image deck containing the 3 images (X1,X2,X3) can be created
%	using D = [X1,X2,X2];
%
%	See also MOVIE, IMSLICE.

%	Clay M. Thompson 5-12-93
%	Copyright (c) 1993 by The MathWorks, Inc.
%	$Revision: 1.5 $  $Date: 1993/09/09 19:18:11 $

error(nargchk(2,2,nargin))

if any(size(a)~=[siz(1) siz(2)*siz(3)]),
  error(['Size of image deck D is not [',int2str(siz(1)),' ', ...
        int2str(siz(2)),' ',int2str(siz(3)),']']);
end

figure(gcf) % Make sure the current figure is in front

% Get some axis properties
pos = get(gca,'position');
vis = get(gca,'visible');
asp = get(gca,'aspectratio');

mov = moviein(siz(3));
for i=1:siz(3),
  imshow(a(imslice(siz,i)))
  set(gca,'position',pos,'visible',vis,'aspectratio',asp)
  mov(:,i) = getframe;
end

