Summing multiple cell entries

조회 수: 18 (최근 30일)
JVoui27
JVoui27 2021년 1월 31일
댓글: JVoui27 2021년 2월 1일
Hi I have a 19x1 cell array F which contains 19 3787x1 cells. How can I sum all of these 19 entries to have a single 3787x1 cell to determine a mean for the data??
F = {3787x1} {3787x1} {3787x1}..... (19 entries)
I've really been struggling to find an efficient code to do this.
  댓글 수: 2
amit kaplan
amit kaplan 2021년 1월 31일
Hi :)
you can try this:
F = repmat({rand(3787,1)},19,1);
F_mat = cell2mat(F);
F_mat = reshape(F_mat,3787,1,19); %is now a {3787x1x19} matrix
F_Sum = sum(F_mat,3); %is now a sum of each layer(cell) into {3787x1} matrix
JVoui27
JVoui27 2021년 2월 1일
Thank you!!

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

채택된 답변

Ive J
Ive J 2021년 1월 31일
Fmat = sum([F{:}], 2);

추가 답변 (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