How to sum two cells element by element?

How to sum two cells element by element by one shot?
if there is a cell A and its size(6,9) and cell B and its size(6,9).
how to do the sumation of A and B element by element?
for example:
sum A{1,1} and B(1,1}
sum A{1,2} and B(1,2} and so on...
and store all the results in another cell

 採用された回答

Matt J
Matt J 2023 年 7 月 19 日
編集済み: Matt J 2023 年 7 月 19 日

0 投票

One way,
A={1,2}, B={10,20},
A = 1×2 cell array
{[1]} {[2]}
B = 1×2 cell array
{[10]} {[20]}
C=cellfun(@plus, A,B,'uni',0)
C = 1×2 cell array
{[11]} {[22]}

1 件のコメント

Matt J
Matt J 2023 年 7 月 19 日
編集済み: Matt J 2023 年 7 月 19 日
Although, it is of course ill-advised to sum cell array contents if they can instead be organized into numerical arrays.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

質問済み:

M
M
2023 年 7 月 19 日

編集済み:

2023 年 7 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by