我想在循环中执行以下操作,以提高效率:
data_Clim1 = griddata(lonClim, latClim, ice_Clim(:,:,1), X, Y);
data_Clim2 = griddata(lonClim, latClim, ice_Clim(:,:,2), X, Y);
data_Clim3 = griddata(lonClim, latClim, ice_Clim(:,:,3), X, Y);
data_Clim4 = griddata(lonClim, latClim, ice_Clim(:,:,4), X, Y);
data_Clim5 = griddata(lonClim, latClim, ice_Clim(:,:,5), X, Y);
data_Clim6 = griddata(lonClim, latClim, ice_Clim(:,:,6), X, Y);
data_Clim7 = griddata(lonClim, latClim, ice_Clim(:,:,7), X, Y);
data_Clim8 = griddata(lonClim, latClim, ice_Clim(:,:,8), X, Y);
data_Clim9 = griddata(lonClim, latClim, ice_Clim(:,:,9), X, Y);
data_Clim10 = griddata(lonClim, latClim, ice_Clim(:,:,10), X, Y);
data_Clim11 = griddata(lonClim, latClim, ice_Clim(:,:,11), X, Y);
data_Clim12 = griddata(lonClim, latClim, ice_Clim(:,:,12), X, Y);
% Add together matrices
data_Clim = [data_Clim1; data_Clim2; data_Clim3; data_Clim4; ...
data_Clim5; data_Clim6; data_Clim7; data_Clim8; data_Clim9; ...
data_Clim10; data_Clim11; data_Clim12];
% Reshape to 3D matrix
data_Clim = reshape(data_Clim, 1437, 159, 12);
基本上,我有一个 360x161x12 的矩阵,我需要将它内插到 1437x159x12。但是,现在,使用 griddata,我一次只能插入一个 z 维度。然后我结合所有单独的矩阵(有 12 个,因为它是每个月一个)并将其重塑为我需要的尺寸。
我假设 while 循环或 for 循环会不那么麻烦。