how to plot with intervals

16 次查看(过去 30 天)
Ismat
Ismat 2023-3-14
评论: Ismat 2023-3-14
I want to plot this with intervals. after taking first data sample will wait for 0.5 sec or 1 sec, then it will draw another data sample.
I used pause function. but it's not working.
schedule=repmat(10,1,5);
actual=randi(12,1,5);
if actual > schedule
battery=actual-schedule;
else
battery=schedule-actual;
end
figure(1)
plot(schedule,'r');hold on
plot(actual,'g');hold on
plot(battery,'b')
legend('schedule','actual','battery')
grid on
ylim([-15 15])

回答(1 个)

Edoardo_a
Edoardo_a 2023-3-14
Hi, I used the pause option and it is working for me...maybe try to increase the timing?
schedule=repmat(10,1,5);
actual=randi(12,1,5);
if actual > schedule
battery=actual-schedule;
else
battery=schedule-actual;
end
figure(1)
plot(schedule,'r');hold on
pause(1)
plot(actual,'g');hold on
pause(1)
plot(battery,'b')
legend('schedule','actual','battery')
grid on
ylim([-15 15])
  1 个评论
Ismat
Ismat 2023-3-14
Thank you very much. Actually, that was not what I was looking for. In my code, I have 5 data samples/points. I want to draw the samples after an interval(any seconds). I just want to update my data samples slowly so that It can easily see the update process.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by