I have a matrix like this
4 3 6 8 1 10 5 2 91 10 3 9 4 2 5 7 69 5 1 7 8 10 3 4 2
What i want to do is a 3×3 matrix that contains this
For cell (1,1) — (4 + 8 + 5) – 4 (i.e. 4(the first element in the array) + 8(the fourth element in the array) + 5(the 7th element in the array) – 4(my initial cell))
For cell (1,2) — (3 + 1 + 2) – 3 (i.e. 3(the second element in the array) + 1(the fifth element in the array) + 2(the 8th element in the array) – 3(my initial cell))
and so on… For cell (2,1) — (1 + 9 + 5) – 1
It's like calculating the total of all the numbers where the indices are separated by 3
output =
13 3 1914 11 810 12 12
Best Answer