how can i find out how many time my for runs?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Image Analyst
2021년 6월 27일
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));
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!