To find the average of values in matrix

2 views (last 30 days)
Sasidharan Subramani
Sasidharan Subramani on 15 Oct 2021
Answered: Star Strider on 15 Oct 2021
I have 32 (131X160) matrices. I want to find the average of 5 elements in each matrices and return in (1X32) matrix.
  2 Comments
Sasidharan Subramani
Sasidharan Subramani on 15 Oct 2021
They are stored as cell array in workspace and I would like to get the index (85,65) to (90,65)

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 15 Oct 2021
Try something like this (assuming that they are stored as elements of a cell array similar to these) —
C = {randn(131,160), randn(131,160), randn(131,160), randn(131,160), randn(131,160)};
Cm = cellfun(@(x)mean(x(85:90,65)), C)
Cm = 1×5
-0.2017 -0.0349 0.2242 0.1696 0.0868
Experiment with the actual cell array to get differnt results.
.

Community Treasure Hunt

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

Start Hunting!

Translated by