how to calculate the execution time of program?

167 次查看(过去 30 天)
When we get desired output in MATLAB.Then how to calculate execution time in MATLAB...

采纳的回答

Dishant Arora
Dishant Arora 2014-2-25
tic
yourCode
timeElapsed = toc
  6 个评论
AVINASH PANDEY
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
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.

请先登录,再进行评论。

更多回答(4 个)

Aaron Corbin
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.

Laith Mohammed
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)

Steven Lord
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.

Barsom
Barsom 2024-10-21
Write a program that reads the departure time of a train and the arrival time and computes and displays the trip time.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by