% a is an nx2 matrix of points, the initial locations, b is an nx2 matrix % of final locations, c is an nx1 vector of colors, m tells how many steps function [void] = animatepoints(a,b,c,m) [s,t] = size(a); clear h ss = s/length(c); i1 = 1:ss; h1 = line(a(i1,1),a(i1,2),'LineStyle','none','Marker','.','Color',c(1)); i2 = (ss+1):2*ss; h2 = line(a(i2,1),a(i2,2),'LineStyle','none','Marker','.','Color',c(2)); for k = 0:m, d = (k/m) * b + (1-k/m) * a; set(h1,'xdata',d(i1,1),'ydata',d(i1,2)); set(h2,'xdata',d(i2,1),'ydata',d(i2,2)); axis([0 2 0 1]); % axis equal % axis off drawnow end