Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB measure a function run time

Tags:

matlab

How to print the time of a function in MATLAB

example:

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

whats the syntax?

like image 331
edgarmtze Avatar asked Feb 22 '11 05:02

edgarmtze


2 Answers

you can also use the nonsingleton forms of tic and toc:

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

This allows the use of more than one timer. (otherwise you have to ensure exclusive use of tic and toc for one measurement)

like image 160
Jason S Avatar answered Oct 13 '22 05:10

Jason S


tic()
A = [2 1 3 ; 1 2 5 ;3 5 4 ]
[U,S,V]            = svd(A)
toc()
like image 27
Dat Chu Avatar answered Oct 13 '22 03:10

Dat Chu