I have a large 3D matrix of air temperatures for the entire Earth, with data formatted as lon x lat x time at hourly resolution. I want to find a reliable way to calculate the daily minimum temperature for each lat / lon location. Example:
lon = -180:10:180;
lat = -90:10:90;
time = datenum('2009-01-01 00:00','yyyy-mm-dd HH:MM'):1/24:datenum('2009-01-05 23:00','yyyy-mm-dd HH:MM');
data = randn(length(lon),length(lat),length(time));
This is my data. It includes air temperature for different places, provided with hourly resolution. The code below is my attempt to calculate the minimum value for each day.
% find number of unique days
datev = datevec(time);
[ia,ib,ic] = unique(datev(:,1:3),'rows');
uic = unique(ic);
% first re-structure data to 2d matrix
rdata = nan(length(time),length(lon)*length(lat));
for i = 1:length(ic);
dd = data(:,:,i);
rdata(i,:) = dd(:);
end
% then calculate the minimum value for each day
min_data = nan(length(uic),length(lon)*length(lat));
for i = 1:length(uic);
idx = find(ic == uic(i));
min_data(i,:) = min(rdata(idx,:),[],1);
end
min_data = reshape(min_data,length(lon),length(lat),length(uic));
I think this answer is correct, at least it looks like when I look at the answers.
, , (1) , (2) , , uniuque. , , 3D-.
.