グラフをアニメーショ​ンで表す際、描画中の​点と描画済みの点を分​けて表示する方法。

조회 수: 12 (최근 30일)
denpika
denpika 2018년 4월 27일
댓글: denpika 2018년 4월 27일
グラフをアニメーションで表す際、描画中の点と描画済みの点を分けて表示できるでしょうか? 例えば、描画している点は'o'とし、描画済みの点はnone(線のみ)とすることです。サークル上になっているグラフのアニメーションも作成したく、線が重なっても現在位置が分かるようにしたいためです。 例えば、以下のような場合です。
figure
axis([-1.5,1.5,-1.5,1.5])
axis square
h = animatedline;
t = 0:0.1:4*pi;
x = cos(t);
y = sin(t);
for k = 1:length(x)
addpoints(h,x(k),y(k));
drawnow
end

채택된 답변

michio
michio 2018년 4월 27일
描画中の点を別途 plot 関数で描き、その点のオブジェクト hcurrent のデータ点の値を更新する形で実現できます。
figure
axis([-1.5,1.5,-1.5,1.5])
axis square
h = animatedline;
hold on
t = 0:0.1:4*pi;
x = cos(t);
y = sin(t);
hcurrent = plot(x(1),y(1),'o');
for k = 1:length(x)
hcurrent.XData = x(k);
hcurrent.YData = y(k);
addpoints(h,x(k),y(k));
drawnow
end
hold off
  댓글 수: 1
denpika
denpika 2018년 4월 27일
解決しました、ありがとうございます。

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 ライン プロット에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!