I have a point in a plot and I want to move it "smoothly" to the other side of the plot within a fixed amount of time. In the example this time is 3s, and I refresh the plot "every 20ms" (20ms is what I want, but it's always more, between: 30 and 50ms). My code is:
interval=3000/20; %3000/20=150
a=0;for i=1:1:interval iTime=clock; set(pointHandle,'Xdata',point(1).coordinatesNow(1)+(500/150),'Ydata',point(1).coordinatesNow(2)); %Only refresh Xaxis
point(1).coordinatesNow(1)=point(1).coordinatesNow(1)+(500/150); pause(0.02); %pause of 20ms
a=a+etime(clock,iTime); %total elapsed time
end disp(a); %show total time
So I'd like "a" to be 3s, but most of the times is between 7 and 10s, How could I get more accuracy?
Best Answer