how to calculate the execution time of program?
조회 수: 114 (최근 30일)
이전 댓글 표시
When we get desired output in MATLAB.Then how to calculate execution time in MATLAB...
댓글 수: 0
채택된 답변
Dishant Arora
2014년 2월 25일
tic
yourCode
timeElapsed = toc
댓글 수: 6
AVINASH PANDEY
2021년 11월 12일
thanku for the information. However, if we repeatedly run the code we get different elapsed time each time. Any explanation regarding this will be highly appreciable.
Steven Lord
2021년 11월 12일
Some minor variation is to be expected. One potential cause of variation is different other processes running at the same time your MATLAB code is running. If you're on Microsoft Windows and Windows Update chooses exactly the time you're running your code to "phone home" for updates that obviously consumes some of the computer's attention, thus potentially making your MATLAB code take longer to run.
추가 답변 (3개)
Aaron Corbin
2014년 3월 1일
편집: Aaron Corbin
2014년 3월 1일
You could also do the following:
before1=clock code... etime(clock,before1)
It subtracts the time before from the time after.
댓글 수: 0
Laith Mohammed
2019년 11월 16일
First you put tic and entering the code that you are working on it after that toc,
Finaly, create a variable called Elapsed_time = toc
Or, you can just wait and matlab will tell you that elapsed time is (XX seconds)
댓글 수: 0
Steven Lord
2021년 11월 12일
tic and toc is one way to measure the performance of your code. Other ways include the timeit function and the Profiler.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!