Why does this code give error?

조회 수: 5 (최근 30일)
Sadiq Akbar
Sadiq Akbar 2023년 2월 15일
댓글: Sadiq Akbar 2023년 2월 16일
I want to implenet timeit() function to find the machine time for the execution of the m-file 'fpa1.m'. But when I run the attached 'main.m', it gives me the following error:
Error using timeit
First argument must be a function handle that takes no input argument.
Error in main (line 6)
fprintf('time taken by fpa1 = %e seconds', timeit(@fpa1,3))

채택된 답변

Walter Roberson
Walter Roberson 2023년 2월 15일
fcn = @() fpa1(10,0.8,2000,4,[-90 -90 -90 -90],[90 90 90 90],@(b)myfunction(b,u,Noise));
timeit(fcn, 3)
  댓글 수: 10
Walter Roberson
Walter Roberson 2023년 2월 16일
The original version of the timeit() function is in the File Exchange. You could load it from there and modify it.
But suppose it gives different output results on different timing iterations, then which version should be output?
Sadiq Akbar
Sadiq Akbar 2023년 2월 16일
Thanks a lot dear Walter Roberson for your kind response. Actually, I have already seached there, the code of the timeit() has been removed from the File Exchange. So, the conclusion is that first, I will run the code for the estimation of outputs and then I will run the code for timeit() because the 'tic-toc' gives wrong timing for estimating different number of values. Thanks a lot once again dear Walter Roberson for your kind response.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by