Azzera filtri
Azzera filtri

Summation of specific range of matrix

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Ive J
Ive J il 2 Gen 2021
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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by