Cellfun to element-wise average cell vectors?

1 Ansicht (letzte 30 Tage)
Philip
Philip am 25 Feb. 2011
Is there a way to use cellfun such that it computes the element-wise average of each element for all cell vectors? (all the arrays are the same size)
I can only find examples where the mean or covariance is calculated for each cell independently...
Thanks!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Feb. 2011
Yes, if you use a function with a persistent variable.
It would, however, be much easier to use:
reshape( mean( reshape(cat(1 + ndims(TheCell{1}), TheCell{:}), [], numel(TheCell)), 2), size(TheCell{1}))
  1 Kommentar
Philip
Philip am 27 Feb. 2011
That's perfect - thanks so much for your help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by