function [imagehandle]=dispstack(stack,frames,frsize,delay)

[ht wd]=size(stack(:,:,1));

imagehandle=figure('Units','pixels','Position',[300 300 wd*frsize ht*frsize]);
drawnow;

smin=min(min(min(stack)));
smax=max(max(max(stack)));

tic
imagehandle=imagesc(stack(:,:,1),[smin smax]); colormap(gray);
set(gca,'Position',[0 0 1 1]);
%set(gca,'Position',[0 0 frsize frsize]);
drawnow;

set(gca, 'xlimmode','manual',...
'ylimmode','manual',...
'zlimmode','manual',...
'climmode','manual',...
'alimmode','manual');

hold on;
axis image;
for i=2:frames

    imagehandle=imagesc(stack(:,:,i),[smin smax]); colormap(gray);
    drawnow;
    pause(delay);
end
toc

clear ht wd min max