Using the sum function

2 visualizzazioni (ultimi 30 giorni)
Farai Mwashita
Farai Mwashita il 28 Ott 2014
Commentato: Andrew Reibold il 28 Ott 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 Commento
Andrew Reibold
Andrew Reibold il 28 Ott 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?

Accedi per commentare.

Risposte (1)

Matt J
Matt J il 28 Ott 2014
Modificato: Matt J il 28 Ott 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