Here's the basic idea. In the following, fixed_x
and fixed_y
are vectors of equal length giving the location of your fixed points.
moving_x
and moving_y
are matrices of size t x n where t is the number of time steps, and n the number of points.
%plot the fixed points
plot(fixed_x,fixed_y, 'p');
hold on
%plot the first set of moving points
h = plot(moving_x(1,:),moving_y(1,:),'r*');
Then, to move the points, we use the handle to the moving points, h
to set XData
and YData
values. This would be within a loop where n
is the time step:
set(h, 'XData',moving_x(n,:),'YData',moving_y(n,:));
%may need drawnow;
If you want to be able to see the points moving, you may need to add some pause
command - otherwise it might cycle through the update loop so quickly you won't see anything except the final set of positions. On the other hand, you could just save out the figure as an image file after you've moved the points with set
, or add it as a frame to a movie, etc.