how to plot repeating steps graph real time/animated
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!