在Matlab中每秒钟打印一次警告 [英] Print out a warning every whole second in Matlab
本文介绍了在Matlab中每秒钟打印一次警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图每秒钟打印一次警告或一条消息,例如已过去1秒". 有可能意识到这一点吗?
I am trying to print a warning or just a message after every second, like "1 second elapsed". Is there a possibility to realize that?
我用tic toc和循环尝试了它,但这还远远不够.而且,我永远也不会得到准确的一秒钟.是否有一个命令每X ms自动打印一次? 有什么想法吗?
I tried it with tic toc and a loop, but it is pretty insufficient. Furthermore I never get exactly one second. Is there a command that prints every X ms automatically? Any ideas?
谢谢.
推荐答案
使用计时器对象.
t = timer;
t.ExecutionMode = 'fixedRate';
t.Period = 1;
t.TimerFcn = @(~,~)disp('1s elapsed');
start(t)
这篇关于在Matlab中每秒钟打印一次警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文