フィルターのクリア

How to add the contents of all cells in a row of a cell array together

2 ビュー (過去 30 日間)
Jocelyne Beelen
Jocelyne Beelen 2016 年 7 月 27 日
回答済み: Star Strider 2016 年 7 月 27 日
Hi,
I've created a cell array that has 1 row. In each element of the cell array is a 3D matrix. I want to add all the matrices in the row of the cell array together. How do I do that?

採用された回答

Star Strider
Star Strider 2016 年 7 月 27 日
The plus function only takes two arguments, so using it with arrayfun failed. A loop is apparently the only option, producing the summed matrix ‘S’:
C = {randi(9, 3, 3, 3), randi(9, 3, 3, 3), randi(9, 3, 3, 3), randi(9, 3, 3, 3)};
S = 0;
for k1 = 1:size(C,2)
S = S + C{k1};
end
This of course assumes all the matrices are the same size, as they are here.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by