how to plot repeating steps graph real time/animated

2 Ansichten (letzte 30 Tage)
Young Woo Kim
Young Woo Kim am 20 Jan. 2023
Kommentiert: Mathieu NOE am 25 Jan. 2023
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.

Akzeptierte Antwort

Mathieu NOE
Mathieu NOE am 20 Jan. 2023
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 Kommentare
Young Woo Kim
Young Woo Kim am 25 Jan. 2023
this helped so much! Thank you very much
Mathieu NOE
Mathieu NOE am 25 Jan. 2023
Glad I could help .
do you mind accepting my answer ?
tx

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by