two animated lines simultaneously with different number of sample
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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!