h = animatedline;
axis([1.5*pi,0,-1,1])

x = linspace(4*pi, 0, 1000);
y = sin(x);
for k = 1:length(x)
    addpoints(h,x(k),y(k));
    drawnow
end