我在matlab中有一个非常奇怪的时差。以下代码(我知道它有点乱)在matlab 2011a上运行得非常快(每次迭代的平均时间为2.5秒),而在matlab 2015b上它平均需要25秒!任何建议为什么会发生这种情况?如果我能在matlab 2015b中得到这个时间,那将会很方便。
for k = 1:length(z),
tic;
file = z(k).name;
sep = fopen([pathf filesep file],'r');
frewind(sep)
icc = 1;
illt=1;
data = [];
while 1
h = fgetl(sep);
if illt==10
LAT(k)=str2num(h(19:20)) + str2num(h(22:26))/60;
elseif illt==11
LON(k)=- (str2num(h(20:22)) + str2num(h(24:28))/60);
elseif illt==12
TIME(k)=datenum(h(21:40));
end
if ~ischar(h), break;
end
if numel(h)==0 || strcmp(h(1),'#') || strcmp(h(1),'*')
illt=illt+1;
else
data(icc,:) = str2num(h);
icc = icc+1;
end
end
[mm nn]=size(data);
iq0 = find(diff(data(:,4)) <=0);
iq=iq0;
q=1;
while data(q,4)<6 , q=q+1; end
position=q;
c=1;
for qq=position:iq
TEMP1(c,k)=data(qq,2);
COND1(c,k)=data(qq,3);
PRESS1(c,k)=data(qq,4);
OOO1(c,k)=data(qq,16);
PTEMP1(c,k)=data(qq,9);
PTEMP2(c,k)=data(qq,19);
SALIN1(c,k)=data(qq,8);
SALIN2(c,k)=data(qq,20);
PDEN1(c,k)=data(qq,15); % sigma-theta, pot. density...
% with effect of adiabatic cooling/heating effect...
%[using potential temperature] and the pressure effect removed
PDEN2(c,k)=data(qq,17); % sigma-t, pot. density at atm. pressure
c=c+1;
end
toc;
end