average value of group of cells in a matrix
Ältere Kommentare anzeigen
hi, i have a question that might souund silly, but i am a beginner in MATLAB. i have a matrix that is 20x20. i want to find the average values for each 4 rows and columns, for example (1:4,1:4) then (1:4, 5:8), ... , (1:4,16:20), then proceed to the next group for until i find the average of the final group which is for (16:20,16:20), and then i want to put them in a list. i know this can be easily done in a for loop (or maybe two for loops), but i am still confused on how to do it. appreciate any help. i put a figure to ease imagining the problem.
what i have so far is:
for i=1:4:20
mean (a(i:i+3,i:i+3),'all')
end
but this gives the average only for the diagonal groups!

1 Kommentar
Sulaymon Eshkabilov
am 1 Jun. 2021
Take a look this help discussion on mean calcs of cell arrays:
https://www.mathworks.com/matlabcentral/answers/315835-mean-values-of-cell-arrays
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements 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!