how can I compare the execution time of two different methods simultaneously in MatLab? actually I used "tic-toc" but I'm not sure if I did it in a correct way or not. this is how I do it:
clc;
clear all;
A=rand(10);
B=rand(50;
tID1=tic;
y1=function1(A,B);
t1=toc(tID1);
tID2=tic;
y2=function2(A,B);
t2=toc(tID2);
timeit- Luis Mendotimeit. There are a lot of subtleties in timing MATLAB code, whichticandtocdo not deal with.timeithandles things properly. In recent versions,timeitis built in to MATLAB, otherwise download by following Luis' link. - Sam Roberts