How to calculate the run time for m.file?
조회 수: 1 (최근 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!