two animated lines simultaneously with different number of sample

4 vues (au cours des 30 derniers jours)
alessandro mutasci
alessandro mutasci le 30 Sep 2021
Commenté : Mathieu NOE le 12 Oct 2021
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

Réponse acceptée

Mathieu NOE
Mathieu NOE le 30 Sep 2021
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 commentaires
alessandro mutasci
alessandro mutasci le 12 Oct 2021
yes! sorry I thought I answered you! thank you so much for your help!
Mathieu NOE
Mathieu NOE le 12 Oct 2021
My pleasure !

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by