sum of doubles of different cells

1 回表示 (過去 30 日間)
Mori
Mori 2016 年 7 月 13 日
コメント済み: Mori 2016 年 7 月 13 日
I have two cells (A & B) which each of them has 5*1 cell and each cell 26*1 doubles. How I sum A and B doubles with together into cell C with 5*1 cell and each cell 26*1 doubles.

採用された回答

Elias Gule
Elias Gule 2016 年 7 月 13 日
This function should do what you want.
function C = cellsum(A,B)
if iscell(A) && iscell(B)
C = cellfun(@(x,y) cellsum(x,y),A,B,'uniform',false);
else
if isnumeric(A) && isnumeric(B)
C = A + B;
else
C = {}; %%Alternatively, throw an error if you like
end
end
  1 件のコメント
Mori
Mori 2016 年 7 月 13 日
thank you, working great.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 13 日
C=cellfun(@(x,y) x+y,A,B,'un',0)
  1 件のコメント
Mori
Mori 2016 年 7 月 13 日
cool! faster

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

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by