Tic and Toc question

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일

0 개 추천

You are close ...
tic
while toc < 1
%do something
end

추가 답변 (1개)

Paulo Silva
Paulo Silva 2011년 8월 10일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2011년 8월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by