how to calculate the execution time of program?
165 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shrivardhan suryawanshi
am 25 Feb. 2014
Beantwortet: Barsom
am 21 Okt. 2024
When we get desired output in MATLAB.Then how to calculate execution time in MATLAB...
0 Kommentare
Akzeptierte Antwort
Dishant Arora
am 25 Feb. 2014
tic
yourCode
timeElapsed = toc
6 Kommentare
AVINASH PANDEY
am 12 Nov. 2021
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
am 12 Nov. 2021
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.
Weitere Antworten (4)
Aaron Corbin
am 1 Mär. 2014
Bearbeitet: Aaron Corbin
am 1 Mär. 2014
You could also do the following:
before1=clock code... etime(clock,before1)
It subtracts the time before from the time after.
0 Kommentare
Laith Mohammed
am 16 Nov. 2019
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 Kommentare
Steven Lord
am 12 Nov. 2021
tic and toc is one way to measure the performance of your code. Other ways include the timeit function and the Profiler.
0 Kommentare
Barsom
am 21 Okt. 2024
Write a program that reads the departure time of a train and the arrival time and computes and displays the trip time.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!