how to plot repeating steps graph real time/animated

1 回表示 (過去 30 日間)
Young Woo Kim
Young Woo Kim 2023 年 1 月 20 日
コメント済み: Mathieu NOE 2023 年 1 月 25 日
the picture is sideways but
Is there a way to animate this sort of graph?
so far I have:
clc, clearvars
h = animatedline;
axis([0,5*pi,0.8,1])
x = linspace(0,5*pi,5000);
y = sin(x);
posY=y(y>0.8);
posX=x(y>0.8);
for k = 1:length(x)
addpoints(h,posX(k),posY(k));
% scatter(posX(k),posY(k));
plot (posX,posY,'.');
end
this is a partial plot of a sine wave but i would like to do a partial plot of a graph like the one I've drawn. Thank you in advance.

採用された回答

Mathieu NOE
Mathieu NOE 2023 年 1 月 20 日
hello
maybe this
%% create animatedline object / handle
figure
h1 = animatedline;
h1.Marker = '*';
h1.Color = [1 0 1];
%% dummy data
x = (1:250);
y = 0.5*(1-square(0.25*x));
axis([0 max(x)*1.1 -0.2 1.2]);
for ci=1:length(x)
addpoints(h1,x(ci),y(ci));
pause(0.1);
drawnow
end
  2 件のコメント
Young Woo Kim
Young Woo Kim 2023 年 1 月 25 日
this helped so much! Thank you very much
Mathieu NOE
Mathieu NOE 2023 年 1 月 25 日
Glad I could help .
do you mind accepting my answer ?
tx

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by