Friday, March 03, 2006

Show image sequence (animation) in Matlab

  • To see the plot animation, force Matlab to draw or pause a while during plotting by using DRAWNOW or PAUSE statment.
  • To avoid zoom effect which may keep your data point in the center of the plot, you have to fix axis coordinates (use axis manual )
  • To only have one 'red-cross', simply draw only one. To animate it, one
    of the solution is to modify XDATA and YDATA properties with the SET
    command.
  • To keep all the red-cross, add 'hold on' after plot and plot(x,y, 'r+')
  • To avoid blinking, try 'set(gcf,'doublebuffer','on');' after plot (only once)
figure
h=plot(0,0,'r+'); hold on;
axis manual;
axis([1 40 1 50]);
%set(gcf,'doublebuffer','on');
for x=1:50
for y=1:40
set(h,'xdata',x,'ydata',y);
% plot(x,y, 'r+'); %if want to keep formers
pause(.1); % or use 'drawnow';
end
end

No comments:

Post a Comment