How to measure running time of a code using MATLAB

조회 수: 325 (최근 30일)
Jose Ricardo Milandro Hibaler
Jose Ricardo Milandro Hibaler 2011년 11월 8일
댓글: Sandip 2023년 12월 16일
Hi. I am new in using MATLAB. I have a thesis about code optimization along with my partner. It was recommended by our adviser to use the software in order t measure the running time of the code. The code is in Java Programming Language. Now, how can I measure the running time of the code using MATLAB?
  댓글 수: 2
Paulo Abelha
Paulo Abelha 2016년 9월 17일
I've coded a function that might help you:
Rehan Ashraf
Rehan Ashraf 2017년 10월 18일
hi; where you want to calculate the time of your code so first you placed tic and toc command in your script.e.g: start tic; code toc

댓글을 달려면 로그인하십시오.

채택된 답변

Lucas García
Lucas García 2011년 11월 8일
  댓글 수: 9
Steven Lord
Steven Lord 2023년 11월 19일
Walter Roberson's comment from 29 Sep 2016 is still valid today.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Taha 2016년 5월 3일
beginn your script with tic and end it with toc. At the end the Elapsed time is showed in MATLAB in seconds.
  댓글 수: 3
Aaya Aboelfotoh
Aaya Aboelfotoh 2019년 6월 11일
Hi Taha,
Is there a way that the elapsed time can be stored as an output? Since I am recording the outputs from matlab to an excel file, i want it to also write the elapsed time as well (instead of manually reading the time and writing it down).
Walter Roberson
Walter Roberson 2019년 6월 11일
your_variable = toc;

댓글을 달려면 로그인하십시오.


Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by