Global Index (short | long) | Local contents | Local Index (short | long)
x = subset2(y, nya, nxa, lims);
x = subset2(y, lat, lon, lims); This returns a matrix x(nlat, nlon) that is a region in y defined by frame lims = [w e s n] limits
This function is called by | |
---|---|
function x = subset2(y, nya, nxa, lims); ndims = sum(size(size(y)))-1; nxak = find(nxa >= lims(1) & nxa <= lims(2)); nyak = find(nya >= lims(3) & nya <= lims(4)); if (ndims == 2); [nlat, nlon] = size(y); if ((length(nya) ~= nlat) | (length(nxa) ~= nlon)); error('Input Y has different dimensions than Inputs lat or lon') end x = y(nyak, nxak); elseif (ndims == 3); [ntim, nlat, nlon] = size(y); if ((length(nya) ~= nlat) | (length(nxa) ~= nlon)); error('Input Y has different dimensions than Inputs lat or lon') end x = y(:,nyak, nxak); elseif (ndims == 4); [ntim, nlev, nlat, nlon] = size(y); if ((length(nya) ~= nlat) | (length(nxa) ~= nlon)); error('Input Y has different dimensions than Inputs lat or lon') end x = y(:,:,nyak, nxak); end