필터 지우기
필터 지우기

How to extract elements from cell arrays and compute the mean of those elements?

조회 수: 1 (최근 30일)
Hello,
I have a 1x11 cell array. Each element in the array is 128 x 1000 matrix (see figure). How can I extract the [9 10 11 12 13 28 29 30 31 32 33 34] from each element and compute the mean of these elements, so that the resultant element will be the mean[9 10 11 12 13 28 29 30 31 32 33 34] x1000 (i.e. 1x1000) in each of the 1x11 cell array. Thanks,

채택된 답변

Rik
Rik 2021년 12월 9일
By far the easiest way is to use a loop.
SubB_M1power={rand(128,3),rand(128,3)};
for n=1:numel(SubB_M1power)
SubB_M1power{n}=mean(SubB_M1power{n},1);
end
SubB_M1power
SubB_M1power = 1×2 cell array
{[0.5482 0.4864 0.5036]} {[0.4972 0.5038 0.5269]}
  댓글 수: 5
Rik
Rik 2021년 12월 9일
Ah yes, excuse the typo, I was a bit too fast in posting my comment.
ET
ET 2021년 12월 9일
Nevermind, Mr. Rik. Thank you for your help. You did solve my problem.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by