我正在使用64GB RAM的Xeon四核处理器。运行该功能的程序只有89个数据点。现在已经超过20分钟了,MATLAB仍然在忙于计算这个程序。下面的代码是否显示计算需要花费很长时间的原因?MATLAB:运行20分钟以上的短功能
function last15MinsOfDay=last15MinsOfDay(time,price)
% last15MinsOfDay takes the average of prices between 3:45 and 4:00.
timeStr=cellstr(datestr(time));
timeDbl=datevec(timeStr);
times=and(timeDbl(:,4)==14,timeDbl(:,5)>=45)+and(timeDbl(:,4)==15,timeDbl(:,5)==0);
priceIdx=find(times);
z=find(fwdshift(1,priceIdx)~=priceIdx+1);
z=[1; z];
mu=zeros(length(z),1);
for i = 1:length(z);
while i < length(z)
mu(i)=mean(price(priceIdx(z(i):z(i+1))));
end
end
last15MinsOfDay=mu;
你明白了!谢谢! – kits