필터 지우기
필터 지우기

How to add marker for the current point in animated line

조회 수: 6 (최근 30일)
Argo Chakraborty
Argo Chakraborty 2021년 9월 19일
댓글: Argo Chakraborty 2021년 9월 19일
clc;clear all; close all
a1 = animatedline('Color',[0 .7 .7]);
a2 = animatedline('Color',[0 .5 .5]);
axis([0 20 -1 1])
x = linspace(0,20,10000);
for k = 1:length(x);
% first line
xk = x(k);
ysin = sin(xk);
addpoints(a1,xk,ysin);
% second line
ycos = cos(xk);
addpoints(a2,xk,ycos);
% update screen
drawnow
pause(0.000001)
end
Hi,
In the above code I want to add a marker to the current point in the plot as shown in the attached fig. So, I want the trajectory to be visible as a line and the current point as a marker.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 9월 19일
Just a plot() with drawnow better simulates the animated plot:
axis([0 20 -1 1])
x = linspace(0,20,1000);
for k = 1:length(x)
% first line
xk = x(k);
ysin = sin(xk);
plot(xk, ysin, 'bo-', 'markerfacecolor', 'y'), hold on
% second line
ycos = cos(xk);
plot(xk, ycos, 'rp-', 'markerfacecolor', 'c'),
% update screen
drawnow
pause(0.0000001)
hold all
end
  댓글 수: 1
Argo Chakraborty
Argo Chakraborty 2021년 9월 19일
Thanks for your reply. But I want that the marker should be visible only for the current point and only a curve (without marker) for the trajectory.

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

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by