function M = chasemovie (robot, target, nframes) % % produces movie file from chase information % axis equal; axis ([-40 40 -40 40]); M = moviein (nframes); for k = 1:nframes hold on % % plot the trails in magenta and blue % for j = max(1, k-5):k-1 axis equal; axis ([-40 40 -40 40]); plot (robot(j,1), robot(j,2), 'm.', target(j,1), target(j,2), 'b.'); end % % plot the new points in red and black % plot (robot(k,1), robot(k,2), 'r.', target(k,1), target(k,2), 'k.'); M(k) = getframe; hold off cla end