MATLAB: Animation without previous states

animationmotion captureplot

Hello,
I would like to plot the position of several markers coming from motion capture. I have no problem to plot them all and to have the trajectory of every markers however there is the previous positions of each markers.
I would like to have only the position at time t of every markers and not to have the t-1, t-2, t-3… positions. I have tried to set hold off but then there is only one marker left, centered in my figure.
There is the code :
close all
clear all
srv = btkEmulateC3Dserver();
acq = btkReadAcquisition('Flugan1.c3d');
markers = btkGetMarkers(acq);
m1=markers.Marker1;
m2=markers.Marker2;
m3=markers.Marker4;
m4=markers.Marker5;
m5=markers.C_4;
m6=markers.C_5;
m7=markers.C_6;
m8=markers.C_7;
m9=markers.C_8;
[x,y,z] = sphere(10);
for i=1081:1:3000
a=mesh(x+m1(i,1),y+m1(i,2),z+m1(i,3));
b=mesh(x+m2(i,1),y+m2(i,2),z+m2(i,3));
c=mesh(x+m3(i,1),y+m3(i,2),z+m3(i,3));
axis equal;
drawnow;
clear figure;
end
If possible I would like to have a slide bar on the bottom of the window to go forward and backward in order to see the movement whenever I want, without running the programm again.
Thank you for your time.

Best Answer

set the axis xlimmode and ylimmode to manual and set appropriate xlim and ylim. This will prevent the constant re-centering you are seeing.
Instead of calling mesh each time through the loop, call mesh (possibly with dummy data) before the loop and record the handles. Then inside the loop, update the XData, YData, ZData properties of those handles.