How to calculate the run time for m.file?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Raghava S N
on 31 Dec 2024
Moved: Walter Roberson
on 31 Dec 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 Comments
See Also
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!