Tic and Toc question

2 次查看(过去 30 天)
Jason
Jason 2011-8-10
Hi everyone, I just have a quick question. How would I numerate my tic and toc so that I can make my program stop after a certain amount of time? I'm trying to say like, while tic<1 (second), continue, but I am most likely doing it wrong. Can anyone help?

采纳的回答

Daniel Shub
Daniel Shub 2011-8-10
You are close ...
tic
while toc < 1
%do something
end

更多回答(1 个)

Paulo Silva
Paulo Silva 2011-8-10
tStart = tic;
for n=1:2000
n
if toc(tStart)>=0.1 %100 miliseconds
disp('time exceeded')
break %if it's a function use return
end
end

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by