MATLAB: How to do multi animated lines in one axes

animatedline

I need to do two multi animated lines in one axes.Is there any solution to this problem? As picture shows: This picture use "plot" ,but It's slowly when close to the end. And the matlab give a suggestion :use animatline to instead the plot function.

Best Answer

Just create a second animatedline and use addpoints:
numpoints = 100000;
x = linspace(0,4*pi,numpoints);
y = sin(x);
y2 = cos(x);
figure
h = animatedline;
h2 = animatedline;
axis([0,4*pi,-1,1])
for k = 1:numpoints
addpoints(h,x(k),y(k))
addpoints(h2,x(k),y2(k))
drawnow update
end
Related Question