MATLAB: Daily max -min , sum, average of hourly data sets.

averagemaxminsum

hi,
I have created one mat file (attached). the first column is dates the second column is temperature- here I want to find daily max and min the third column is rainfall- here daily sum I don't need 4th and 5th column but for this time make an average.
in the date column, time is not given but it is an hourly data.(same date 24 times.)
i hope you understand

Best Answer

[y,m,d] = datevec(tempdata(:,1));
[a,~,c] = unique([y,m,d],'rows');
out = [a, zeros(size(a,1),7)];
out(:,4) = accumarray(c,tempdata(:,2),[],@nanmin);
out(:,5) = accumarray(c,tempdata(:,2),[],@nanmax);
out(:,6) = accumarray(c,tempdata(:,3),[],@nansum);
[ii,jj] = ndgrid(c,1:4);
out(:,7:10) = accumarray([ii(:),jj(:)],reshape(tempdata(:,4:7),[],1),[],@nanmean);