Hi everyone! Now, i want to draw two animated plots on each subplots at the same time. You can see my code below. But, when i use this code, of course, Matlab will return two subplots and it will draw "k" line after drew "r" line. So, how can i do to draw two animated plots (in this case is two lines) at the same time? Thank you so much. My code:
x1=linspace(0,20,201);y1=sin(x1);x2=linspace(0,20,201);y2=cos(x2);sub1=subplot(2,1,1);hold onaxis([0 21 -1.1 1.1]); ani1=animatedline('Color','r');for i=1:length(x1) addpoints(ani1,x1(i),y1(i)); drawnow pause(0.01);endsubplot(2,1,2)hold onaxis([0 21 -1.1 1.1]); ani2=animatedline('Color','k');for j=1:length(x1) addpoints(ani2,x1(j),y1(j)) drawnow pause(0.01);end
Best Answer