sum of doubles of different cells

2 visualizaciones (últimos 30 días)
Mori
Mori el 13 de Jul. de 2016
Comentada: Mori el 13 de Jul. de 2016
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.

Respuesta aceptada

Elias Gule
Elias Gule el 13 de Jul. de 2016
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

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jul. de 2016
C=cellfun(@(x,y) x+y,A,B,'un',0)

Categorías

Más información sobre Time Series en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by