You can do the following. Let pos be an Nx3 matrix containing data of x, y, z points, for N instances of time. You write the main script that sets vars, etc., and create a t1 loop timer that calls the doPlot build function. The main script:
clear all clc pos=rand(100,3)*10; %position matrix of random x,y,z coordinates. 100 time instances here ax=axes; set(ax,'NextPlot','replacechildren'); axis([0 10 0 10 0 10]); %set axis limits- fit to your needs Dt=0.1; %sampling period in secs k=1; hp=plot3(pos(k,1),pos(k,2),pos(k,3),'o'); %get handle to dot object t1=timer('TimerFcn','k=doPlot(hp,pos,t1,k)','Period', Dt,'ExecutionMode','fixedRate'); start(t1);
Then you create a doPlot build function,
function k=doPlot(hp,pos,t1,k) k=k+1; if k<length(pos) set(hp,'XData',pos(k,1),'YData',pos(k,2),'ZData',pos(k,3)); axis([0 10 0 10 0 10]); else stop(t1) end
You will see a point (circle) in 3D randomly moving in space. The animation period is Dt secs (in this case, 0.1 s). You have to fit your needs. This is the basic animation in Matlab. You could do so much more. It depends on your needs.