比较函数的结果,并将其作为矩阵放到MATLAB中

比较函数的结果,并将其作为矩阵放到MATLAB中,matlab,Matlab,假设我在Matlab中得到两个函数的执行时间,我有一个循环来获得不同的测量值: for i = 0: 100 Start1 = tic; somefunction1; Total1 = toc(Start1); Start2 = tic; somefunction2; Total2 = toc(Start2); end; 如何获得具有以下时间结果的mtarix: iteration times1 times2 1

假设我在Matlab中得到两个函数的执行时间,我有一个循环来获得不同的测量值:

for i = 0: 100
    Start1   = tic;
    somefunction1;
    Total1   = toc(Start1);

    Start2   = tic;
    somefunction2;
    Total2   = toc(Start2);
end;
如何获得具有以下时间结果的mtarix:

iteration times1      times2
  1       someval1     someval1
  2       someval2     someval2
  3       someval3     someval2
 ...
它们可以插入另一个矩阵吗?怎么做

------------------------------------编辑 我已经做了这个建议,它很有效:


将Total1和Total2组合成一个矩阵

N = 100;
Total = zeros(N,2);
...
Total(i,1) = toc(Start1);
...
Total(i,2) = toc(Start2);
我会将迭代作为一个单独的向量:

iteration = 1:N;
然后可以绘制结果,例如:

plot(iteration,Total)
plot(iteration,Total)