Using the sum function

5 Ansichten (letzte 30 Tage)
Farai Mwashita
Farai Mwashita am 28 Okt. 2014
Kommentiert: Andrew Reibold am 28 Okt. 2014
Hello
I have a variable dailyHDD=(1x365) which represents the daily temperature for each day of the year. I am trying to calculate the total for each month and I am not sure sure to do it, In this column 1-31 will be january month. please can you assist on how to break this into 12 months and calculate the total for each month.
Regards
Farai
  1 Kommentar
Andrew Reibold
Andrew Reibold am 28 Okt. 2014
....You say the 'total' for each month as if you want the sum. Your situation however makes it sound more practical to have the mean.
Do you really want the sum?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 28 Okt. 2014
Bearbeitet: Matt J am 28 Okt. 2014
[~,m]=datevec(1:365);
totals=accumarray(m,dailyHDD(:))

Community Treasure Hunt

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

Start Hunting!

Translated by