在myprog文件中加入自己要执行的程序代码,然后执行
profile on -memory
myprog
profile viewer
myprog中测试代码:
% clear
% clc
tic
a = rand(100000, 500);
%主机电流
at = a(:,1);
%泵的转速
vt = a(:,2);
%出水温度
iwto = a(:,3);
%回水温度
iwti = a(:,4);
%外气温度
temo = a(:,5);
a1 = a(:,6);
a2 = a(:,7);
a3 = a(:,8);
a4 = a(:,9);
a5 = a(:,10);
x1 = iwti;
x2 = temo./at;
x3 = a1.*a4./a3;
x4 = a2+a3.*a5./a4;
x = [ones(size(x1)),x1,x2,x3,x4];
y = 4.2*vt.*(iwti-iwto);
%least square
a = x\y;
[chiller,se_b,mse] = lscov(x,y);
toc
% [status,info]=dos('@echo off &for /f "tokens=4,5*" %i in (''tasklist ^|findstr /r /I "matlab.exe"'') do echo %j');
%
% info(find(info=='K'))=[];
% info(find(info == ',')) = [];
% sprintf('Matlab used memory : %.0f KB',str2num(info))
会出现下图:
对数据的操作占用大部分时间,做数据拟合消耗的时间只占很小的比例。
不做内存释放,如果数组的大小不发生变化,那么执行时间和内存消耗值不会发生变化。
具体参考另一篇博文: