To find the average of values in matrix

조회 수: 2 (최근 30일)
Sasidharan Subramani
Sasidharan Subramani 2021년 10월 15일
답변: Star Strider 2021년 10월 15일
I have 32 (131X160) matrices. I want to find the average of 5 elements in each matrices and return in (1X32) matrix.
  댓글 수: 2
Jan
Jan 2021년 10월 15일
How are the 32 matrices stored? As fields of a struct, as cell array, as numerical 3D array?
Which 5 elements are you interested in? How are they given? As indices, logical index or values?
Sasidharan Subramani
Sasidharan Subramani 2021년 10월 15일
They are stored as cell array in workspace and I would like to get the index (85,65) to (90,65)

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2021년 10월 15일
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.
.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by