# How to calculate mean across the elements of a cellarray?

141 views (last 30 days)
DEEPAK PHCSFI17041149 on 28 Dec 2017
Answered: Image Analyst on 28 Dec 2017
I have a cellarray A of dimension 64x8 with elements in the following dimension,
520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double
520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double
520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double
...............
Now i need to take MEAN across the 8 rows in each column, so that i will get just one 520x1 cell per row.
so, after applying mean across rows, my output should be something like,
520x1 double
520x1 double
520x1 double
520x1 double
520x1 double
520x1 double
............
............
So, my output would be a 64x1 cell array transformed from 64x8.
i tried with doing this with the following command,
avgCell = {mean(cat(3,C{:}),3)}
But, it gives 1x1 cell array with just one cell of dimension 520x1.
Kindly correct me, and suggest me if there is any function to deal with this.

Image Analyst on 28 Dec 2017
Try using cell2mat(), then mean(). Attach your cell array in a .mat file with the paper clip icon if you can't figure it out.