How to sum over 3 dimensional cell array, where each cell also contains cells?

조회 수: 1 (최근 30일)
I have a 6x6x645 cell array, call it cellArray. So for each element i, where , of cellArray(:,:,i) we have a 6x6 cell. Each of these 6x6 cells themselves have 1x3 double matrices at every entry. For example for i=5:
cellArray(:,:,5) =
{1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double}
{1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double}
{1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double}
{1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double}
{1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double}
{1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double} {1×3 double}
These 1x3 matrices are confindence intervals with [lowerbound,estimate,upperbound]. My goal is to sum all the confidence intervals over the 645 cells such that we are left with one 6x6 cell containing 1x3 matrices with the sums of all the intervals. How do you sum over this?

채택된 답변

Matt J
Matt J 2019년 7월 5일
편집: Matt J 2019년 7월 5일
I'm tempted to ask how this data got to be a cell array, when it should really have been a 3x6x6x645 numeric array. We can fix that, though:
A=reshape( cat(4,cellArray{:}) ,3,6,6,[]);
result = sum(A,4);
  댓글 수: 1
Jeroen
Jeroen 2019년 7월 5일
You are right, I should not have put the confidence intervals in one cell. The script had to run for 4,5 hours, so better to reshape now than to run again. Thank you!!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by