two animated lines simultaneously with different number of sample

조회 수: 2(최근 30일)
alessandro mutasci
alessandro mutasci 2021년 9월 30일
댓글: Mathieu NOE 2021년 10월 12일
good evening, I'm trying to animate two line simultaneously, but I cant. I attach one if the last script, I even tried with only one for and the hold on after thefirst animatedline but still nothing.. I hope some can help me. I attach the 4 vector. x is with y; x1 with y1.
h = animatedline;
h1=animatedline;
axis([0,12,0,1])
numpoints = 2000;
numpoints1 = 20000;
x1=len_x1;
y1=len_y1;
x = len_x;
y = len_y;
a = tic; % start timer
% c=tic;
for k = 1:numpoints
addpoints(h,x(k),y(k))
b = toc(a); % check timer
if b > (1/100)
drawnow % update screen every 1/100 seconds
a = tic; % reset timer after updating
end
end
hold on
for j = 1:numpoints1
addpoints(h1,x1(j),y1(j))
b = toc(a); % check timer
if b > (1/10)
drawnow % update screen every 1/100 seconds
a = tic; % reset timer after updating
end
end
drawnow % draw final frame

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 9월 30일
hello
I am not sure to uderstand what kind of result you want to achieve , maybe this little demo can help you
clearvars
clc
figure
h1 = animatedline;
h1.Marker = '*';
h1.Color = [1 0.4 0];
h2 = animatedline;
h2.Marker = '+';
h2.Color = [0 1 0];
axis([0 2*pi -1.5 1.5])
% x, y data
n = 100;
x=linspace(0,2*pi,n);
y1 = sin(x);
y2 = cos(x);
% main loop
for ci=1:n
addpoints(h1,x(ci),y1(ci));
addpoints(h2,x(ci),y2(ci));
pause(0.01);
drawnow
end
  댓글 수: 7

댓글을 달려면 로그인하십시오.

추가 답변(0개)

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by