Summing multiple cell entries

32 Ansichten (letzte 30 Tage)
JVoui27
JVoui27 am 31 Jan. 2021
Kommentiert: JVoui27 am 1 Feb. 2021
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 Kommentare
amit kaplan
amit kaplan am 31 Jan. 2021
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 am 1 Feb. 2021
Thank you!!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Ive J
Ive J am 31 Jan. 2021
Fmat = sum([F{:}], 2);

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by