Cellfun to element-wise average cell vectors?

3 ビュー (過去 30 日間)
Philip
Philip 2011 年 2 月 25 日
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!

採用された回答

Walter Roberson
Walter Roberson 2011 年 2 月 25 日
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 件のコメント
Philip
Philip 2011 年 2 月 27 日
That's perfect - thanks so much for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by