Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)
[a2,lat2,lon2] = area_mean(a, inc, lat, lon);
[a2, lat2, lon2] = area_mean(in1, inc, lat, lon); Thin will condense the matrix in1 by averaging over every inc element in each direction. This program assumes the input data is three- dimensional, with time, lat, lon, as the dimensions.
| This function calls | |
|---|---|
function [a2,lat2,lon2] = area_mean(a, inc, lat, lon);
[ntim, nlat, nlon] = size(a);
nlat2 = floor(nlat/inc(1));
nlon2 = floor(nlon/inc(2));
a2 = repmat(NaN, [ntim, nlat2, nlon2]);
% Average the data
for i = 1:nlat2;
ind1 = inc(1)*(i-1)+[1:inc(1)];
for j = 1:nlon2;
ind2 = inc(2)*(j-1)+[1:inc(2)];
a2(:,i,j) = squeeze(mean2(mean2(shiftdim(a(:,ind1,ind2),1))))';
end
end
% Do the same for lat and lon
if nargin == 4;
lat2 = repmat(NaN, [nlat2, 1]);
for i = 1:nlat2;
ind1 = inc(1)*(i-1)+[1:inc(1)];
lat2(i) = mean(lat(ind1));
end
lon2 = repmat(NaN, [nlon2, 1]);
for i = 1:nlon2;
ind1 = inc(2)*(i-1)+[1:inc(2)];
lon2(i) = mean(lon(ind1));
end
end