How to calculate the run time for m.file?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Raghava S N
2024 年 12 月 31 日
移動済み: Walter Roberson
2024 年 12 月 31 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Performance and Memory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!