Update, I have modified some lines to suit my purpose. However, there are lines confused me.
I.e if I do it like below, the code runs smoothly
if(i<(scrollWidth/delay))
set(plotGraph,'XData',time,'YData',data);
axis([0 scrollWidth min max]);
else
set(plotGraph,'XData',time,'YData',data);
axis([time(i)-scrollWidth time(i) min max]);
end
If I do it like this
if(i<(scrollWidth/delay))
set(plotGraph,'XData',time,'YData',data);
axis([0 scrollWidth min max]);
else
set(plotGraph,'XData',time,'YData',data);
axis([time(i -(scrollWidth/delay)) time(i) min max]);
%time(i-(scrollWidth/delay)) = time(i)-delay
end
then the code stop at i = scrollWidth/delay (in this case, i=100). Can someone explain my problem? I suppose Matlab can access previous values of time(i) while in a loop, but it doesnt make sense to me. Many thanks