我有大约2400个文件(其中一些是tsv,其他是.txt)。我被告知他们是72x144(但我没有全部检查)。当我运行这个脚本时:
load area.mat %Area Calculation %
%area= transpose(area);
area= repmat(area,1,144); % replicating the vector area 144 times
files= dir('200*'); % loading files of June
for m=1:length(files)
June(:,:,m)= dlmread(files(m).name); % loading files in a 3 dimensional %matrix
end
June(June<0)= NaN; % replacing outliers by Not a Number NaN
outliers = isnan(June); % detect NaNs
t= 1:numel(June); % creating a variable t which take values from 1 to number %of elements of matrix June
June(outliers) = interp1(t(~outliers), June(~outliers), t(outliers),'nearest'); % interpolating NaNs by nearest values
z= mean(June,3); % obtaining a matrix June that consists of averages of same cells
June_temp= z.*area; % weighing temperatures by fractions of areas ???????
June_AvgTemp= sum(June_temp(:));
fprintf('The average temperature of June is %0.4f Kelvins, %0.4f degrees Celsius\n',June_AvgTemp,June_AvgTemp-273.15)
我收到错误:
订阅的分配维度不匹配。
almost_F_script中的错误(第16行) 六月(:,:,m)= dlmread(files(m).name); %在3维矩阵中加载文件
我真的很感谢你的帮助!!谢谢
答案 0 :(得分:-1)
问题是由于我使用的是72x144的.TVS文件,以及1x10368的.txt文件作为我的数据集。我刚刚将相同的数据转换为.txt文件,然后我重新设置循环的结果,即6月到72x144,一切正常。无论如何,谢谢你的帮助!