フィルターのクリア

Summation of specific range of matrix

1 回表示 (過去 30 日間)
Victoria Pake
Victoria Pake 2021 年 1 月 2 日
コメント済み: Victoria Pake 2021 年 1 月 2 日
Dear all,
I have an 2464x2464 matrix and sorted by countries alpabethwise such that the first 56 rows represent a country, the 56 rows another and so on . i want to calculate the sum of the 56 rows per country such that i end up with a 44x1 matrix, which represent 1 value per country. I did it for the first country by using
Q_aus = sum(sum(Q_all(1:56,:),2))
How can I write a loop to do this for the whole matrix, without doing it by hand ?
Thanks in advance

採用された回答

Ive J
Ive J 2021 年 1 月 2 日
n = size(Q_all, 1)/56;
Q_aus = (0);
for i = 1:44
Q_aus(i, 1) = sum(sum(Q_all(56*i-55:56*i,:),2));
end
  1 件のコメント
Victoria Pake
Victoria Pake 2021 年 1 月 2 日
Thanks a lot

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by