Tic and Toc question

8 vues (au cours des 30 derniers jours)
Jason
Jason le 10 Août 2011
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?

Réponse acceptée

Daniel Shub
Daniel Shub le 10 Août 2011
You are close ...
tic
while toc < 1
%do something
end

Plus de réponses (1)

Paulo Silva
Paulo Silva le 10 Août 2011
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

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by