daily max -min , sum, average of hourly data sets.?

3 Ansichten (letzte 30 Tage)
pruth
pruth am 19 Okt. 2016
Bearbeitet: pruth am 28 Okt. 2016
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

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 20 Okt. 2016
[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);
  2 Kommentare
pruth
pruth am 24 Okt. 2016
thank you sir.
pruth
pruth am 28 Okt. 2016
Bearbeitet: pruth am 28 Okt. 2016
sir, what shall I do if want repeats this process after every 3 column?
min max for the first column, the sum of the second column, mean for the third column,
and again action repeats . min max for the fourth column and so on...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Steven Lord
Steven Lord am 19 Okt. 2016
If you're using release R2016b or later, I recommend storing your data in a timetable and using the retime function to aggregate data over daily time bins as shown in the second example, "Aggregate Timetable Data and Calculate Mean Values", on that documentation page.
  1 Kommentar
pruth
pruth am 20 Okt. 2016
Bearbeitet: pruth am 20 Okt. 2016
hello steven , thanks for the reply,
I use R2013a.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by