フィルターのクリア

Summing matrices of cell arrays

2 ビュー (過去 30 日間)
Diego Tasso
Diego Tasso 2012 年 6 月 14 日
So i have three cell class variables size of 101x5. I need to combine the three of them to form only one cell array of size 101X5. I have tried concatinating the matrices before summing them and I get an error saying "Undefined function 'sum' for input arguments of type 'cell'."How can I get around this?

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 14 日
num2cell( sum( cat(3,cell2mat(V1), cell2mat(V2), cell2mat(V3)), 3) )
This depends upon the individual cells holding scalars. If they do not then
cellfun(@(A,B,C) A+B+C, V1, V2, V3, 'Uniform', 0)
  4 件のコメント
Diego Tasso
Diego Tasso 2012 年 6 月 14 日
I do not want to sum strings....they are just the name the previous coding person used....its just a variable name. I want to sum the cell arrays. I tried concatinating the cells before summing them in another dimension as you suggested above but I got the error I commented previously about cell2mat not supporting cell arrays containig cell arrays. Should I not concatinate before summing?
Diego Tasso
Diego Tasso 2012 年 6 月 14 日
I was tring to sum cell arrays of strings.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by