필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by