Using the sum function

2 ビュー (過去 30 日間)
Farai Mwashita
Farai Mwashita 2014 年 10 月 28 日
コメント済み: Andrew Reibold 2014 年 10 月 28 日
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 件のコメント
Andrew Reibold
Andrew Reibold 2014 年 10 月 28 日
....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?

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2014 年 10 月 28 日
編集済み: Matt J 2014 年 10 月 28 日
[~,m]=datevec(1:365);
totals=accumarray(m,dailyHDD(:))

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by