【发布时间】:2016-05-18 12:40:15
【问题描述】:
我正在尝试添加一个计时器来模拟我正在进行的模拟。目前我可以让计时器显示在我想要的位置,但是我不能让数字相互清除,即它们都只是慢慢地堆叠在一起,形成一个纯黑色的混乱。我试过实现一个 clf 函数,但它只是清除了整个数字。定时器的代码是:
HH = 0; MM = 0; SS = 0;
timer = sprintf('%02d:%02d:%02d',HH,MM,SS);
text(-450,450,timer); %% adjust location of clock in graph using the first two arguments: (x,y) coordinates
for t = 1:86400
SS = SS + 1;
if SS == 60
MM = MM + 1;
SS = 0;
end
if MM == 60
HH = HH + 1;
MM = 0;
end
timer = sprintf('%02d:%02d:%02d',HH,MM,SS); %% construct time string after all adjustments to HH, MM, SS
clf(f,'reset'); %% clear previous clock display
text(-450,450,timer); %% re-plot time to figure
if t == EventTimes(1)
uav1 = uav1.uavSetDestin([event1(2:3) 0]);
plot(event1(2),event1(3),'+')
hold on
end
if t == EventTimes(2)
uav2 = uav2.uavSetDestin([event2(2:3) 0]);
plot(event2(2),event2(3),'r+')
hold on
end
有没有办法只重置计时器功能,使其正常显示?
【问题讨论】:
标签: matlab plot timer simulation figure