MATLAB Answers


cell mean from each cells

Asked by Kuang-Yu WANG on 26 Jun 2018
Latest activity Commented on by Walter Roberson
on 26 Jun 2018
I need to get the result like this
mean(cellfun(@(x) x(1,4), thething))
mean(cellfun(@(x) x(2,4), thething))
mean(cellfun(@(x) x(n,4), thething))
however my cell are
thething = {26*7 double}
{33*7 double}
{100*7 double}
.....{22*7 double}
not all cells have n lines.I need to use the cells that do have datas to calculate the means to form a plot. thanks!


sorry i entered the wrong code orz
Walter Roberson
on 26 Jun 2018
Please do not close questions that have an answer.

Sign in to comment.


1 Answer

Answer by KL
on 26 Jun 2018

It doesn't matter how many lines each cell has. Probably you want something like,
C = {rand(50,7),rand(30,7),rand(100,7)}; %example
C_means = cellfun(@mean,C,'uni',0)


Sign in to comment.