如果您的数据位于不同的矩阵中,则可以使用eval将平均值存储到某个矩阵,在本例中为MeanMatrix ,其中Y维度为年,X维度为月份:
编辑:它不是从5611运行的数字,但是yymm ...
编辑:似乎矩阵不是从1956年1月开始,而是从1956年11月开始。
% add here missing months matrix index strings.
MissingMatricesCellArray = {'5601', '5602', '5603', '5604', '5605', '5606', '5607', '5608', '5609', '5610'};
% MissingmatricesCellArray = {};
for Year = 56:99
for Month = 1:12
NumString = sprintf('%02d%02d', Year, Month);
% calculate and store means only for matrices that are not missing.
if ~(ismember (cellstr(NumString), MissingMatricesCellArray))
MeanMatrix(Year,Month) = mean(mean(eval ([ 'matrix', NumString ])));
end
end
end
然后,您可以按照您希望的方式比较月份和年份的平均值。
温馨提示:答案为网友推荐,仅供参考