how can i find out how many time my for runs?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
HADIMARGO
am 27 Jun. 2021
Kommentiert: HADIMARGO
am 27 Jun. 2021
so i have a code.
i put it in a for loop to repeat it 10.000 Times!
I want to know how many times it has been repeated?
how could i found this?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 27 Jun. 2021
Try this
startTime = tic;
loopCounter = 1;
for k = 1 : 10
% Some code which may cause the loop to break early....
if iNeedToQuitEarlyCondition
% Something happened where we no longer want to do all 10 iterations.
break;
end
% Increment how many times the loop actually finished:
loopCounter = loopCounter + 1;
end
fprintf('The loop executed %d times in %d seconds.\n', loopCounter, toc(startTime));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!