Loop with Fixed time

4 vues (au cours des 30 derniers jours)
Jen-Yu Hsiao
Jen-Yu Hsiao le 3 Fév 2013
How can I make the loop with fixed time?
For example:
for i=1:5
 somecode;
end
I want to make every calculation time of the loop is about 1 sec And the total calculation time is about 5 sec

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 3 Fév 2013
for i=1:5
%somecode;
pause(1-tw) % tw is your computing time
end
%to find your computing time use tic and toc
  2 commentaires
Jen-Yu Hsiao
Jen-Yu Hsiao le 5 Mar 2013
TKS~!!
Jan
Jan le 5 Mar 2013
Modifié(e) : Jan le 5 Mar 2013
The Java sleep() timer is more accurate: see http://undocumentedmatlab.com/blog/pause-for-the-better/. A timer might be even more precise.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by