필터 지우기
필터 지우기

Averaging multiple matrices with the cell array

조회 수: 7 (최근 30일)
Abdulhakim Alezzi
Abdulhakim Alezzi 2021년 1월 31일
댓글: Star Strider 2021년 2월 1일
Hi Guys,
I have a cell array (C) with (1*22), inside this cell i have 22 matrices with (30*30*20).
I want to have the average of all these matrices, so the final output must be in the same dimention (30*30*20).
I have tried this code, but the output was different
for f=1:1:length(C)
for i=1:30
for j=1:20
data=cell2mat(C(f));
end
end
end

채택된 답변

Star Strider
Star Strider 2021년 1월 31일
Try this:
Cmean = mean(cat(4,C{:}),4);
That concatenates the cells across dimension 4 and then takes the mean across dimension 4.
  댓글 수: 2
Abdulhakim Alezzi
Abdulhakim Alezzi 2021년 2월 1일
Thank you very much
Star Strider
Star Strider 2021년 2월 1일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by