How to calculate the run time for m.file?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have m. file and I want to calculate its run time I, I convert the m.file to functiion and call it in another file
state1 = finalisa3() tt=timeit(state1)
but I get error " Undefined function 'timeit' for input arguments of type 'char'.
Error in ch (line 36) tt=timeit(state1)"
0 commentaires
Réponses (1)
Raghava S N
le 31 Déc 2024
Déplacé(e) : Walter Roberson
le 31 Déc 2024
Hi,
The input to the function "timeit" should be a function handle as mentioned in the documentation - https://www.mathworks.com/help/matlab/ref/timeit.html#btx36ta-f:~:text=Function%20to%20be%20measured%2C%20specified%20as%20a%20function%20handle.%20f%20is%20either%20a%20handle%20to%20a%20function%20that%20takes%20no%20input%2C%20or%20a%20handle%20to%20an%20anonymous%20function%20with%20an%20empty%20argument%20list.
For an example that demonstrates the usage of the "timeit" function to measure code performance, refer to this link - https://www.mathworks.com/help/matlab/ref/timeit.html#d126e1852968:~:text=Compare%20Time%20to%20Execute%20Custom%20Preallocation%20to%20Calling%20zeros.
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!