MATLAB测量函数运行时间

cMi*_*nor 5 matlab

如何在MATLAB中打印函数的时间

例:

%%%TAKE TIME
A = [2 1 3 ; 1 2 5 ;3 5 4 ]
[U,S,V]            = svd(A)
%%%FINISH TIME
Run Code Online (Sandbox Code Playgroud)

什么是语法?

Jas*_*n S 13

你也可以使用tons 和toc的非单体形式:

tStart=tic;
A = [2 1 3 ; 1 2 5 ;3 5 4 ]
[U,S,V]            = svd(A)
tElapsed=toc(tStart);
Run Code Online (Sandbox Code Playgroud)

这允许使用多个计时器.(否则你必须确保独家使用tictoc进行一次测量)


Dat*_*Chu 12

tic()
A = [2 1 3 ; 1 2 5 ;3 5 4 ]
[U,S,V]            = svd(A)
toc()
Run Code Online (Sandbox Code Playgroud)