Summing up values in a matrix
Ältere Kommentare anzeigen
I have a 4D matrix, I(i,j,y,x) which has dimensions of 64 x 64 x 70 x 160. For each coordinate in y and x I'd like to sum all the values for I across i and j to form a 2D matrix I_y_x. i.e. I_y_x(0,0) = I(1,1,0,0)+I(1,2,0,0)+I(1,3,0,0) + .... + I(2,1,0,0) etc.
Thanks in advance
Antworten (1)
Matt J
am 4 Jan. 2021
sum(l,[1,2])
2 Kommentare
Jonathan Bird
am 4 Jan. 2021
Bearbeitet: Jonathan Bird
am 4 Jan. 2021
Just add a squeeze() or a reshape() operation
l=rand(64 , 64 , 70 , 160);
result=squeeze(sum(l,[1,2]));
whos result
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!