how to plot repeating steps graph real time/animated

2 vues (au cours des 30 derniers jours)
Young Woo Kim
Young Woo Kim le 20 Jan 2023
Commenté : Mathieu NOE le 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.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by