% 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 [f] = animatepoints(a,b,c,m,f) [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-1), 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 equal axis([0 2 0 1]); drawnow saveas(gcf,['frames\Baker_gif_' num2str(f) '.png'],'png'); f = f + 1; end