Borrar filtros
Borrar filtros

Summation of specific range of matrix

1 visualización (últimos 30 días)
Victoria Pake
Victoria Pake el 2 de En. de 2021
Comentada: Victoria Pake el 2 de En. de 2021
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

Respuesta aceptada

Ive J
Ive J el 2 de En. de 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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by