MATLAB: How to add two cell arrays of the same dimensions

cell arrayscell matrixsum

I have two cell arrays A and B, each of size 1×5 cells. Each cell is a row vector with different size (A{1}=B{1}=1×4 vector, A{2}=B{2}=1×5 vector…) where each cell in A is the same size of the corresponding cell in B. How can I add A+B?

Best Answer

Try this:
A = [{rand(1,4)} {rand(1,5)}];
B = [{rand(1,4)} {rand(1,5)}];
Out = cellfun(@plus, A, B, 'Uni',0)