您的位置:首页 > 编程语言 > MATLAB

MATLAB中运行时间的函数

2009-11-23 15:44 337 查看
clear;
sqr = zeros(1,1000);
tic;
for ii = 1:1000
sqr(ii) = ii.^2;
end
tim = toc;
fprintf('version: tic --toc : the for statements use time %15.5f./n',tim);

clear;
sqr = zeros(1,1000);
tim = cputime;
for ii = 1:1000;
sqr(ii) = i.^2;
end
tim = cputime - tim;
fprintf('version:cputime : the for statememts use time %15.5f./n',tim);

clear;
sqr = zeros(1,1000);
tim = clock;
for ii = 1:1000
sqr(ii) = i.^2;
end
tim = etime(clock,tim);
fprintf('version:clock--etime : the for statements use time %15.5f./n',tim);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: