Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Star Strider
Star Strider el 27 de Jul. de 2016
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.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by