Using the sum function

1 vue (au cours des 30 derniers jours)
Farai Mwashita
Farai Mwashita le 28 Oct 2014
Commenté : Andrew Reibold le 28 Oct 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 commentaire
Andrew Reibold
Andrew Reibold le 28 Oct 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?

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 28 Oct 2014
Modifié(e) : Matt J le 28 Oct 2014
[~,m]=datevec(1:365);
totals=accumarray(m,dailyHDD(:))

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by