Comparing results of functions and put them as a matrix MATLAB
Let's say I am getting the execution time of two funcion in Matlab, I have a loop to get different measurements:
for i = 0: 100
Start1 = tic;
somefunction1;
Total1 = toc(Start1);
Start2 = tic;
somefunction2;
Total2 = toc(Start2);
end;
How would I get a mtarix with the results of times like:
iteration times1 times2
1 someval1 someval1
2 someval2 someval2
3 someval3 someval2
...
Could they be inserted in another matrix? How?
-----------------------------------EDIT I have done the suggestion and it works:
N = 100;
Total = zeros(N,2);
f开发者_开发问答or i = 1: N
Start1 = tic;
%somefun1
Total(i,1) = toc(Start1);
Start2 = tic;
%somefun2
Total(i,2) = toc(Start2);
end;
Combine Total1 and Total2 into one matrix.
N = 100;
Total = zeros(N,2);
...
Total(i,1) = toc(Start1);
...
Total(i,2) = toc(Start2);
I would keep iteration as a separate vector:
iteration = 1:N;
Then you can plot the results, for example:
plot(iteration,Total)
精彩评论