sum of two cell arrays with different dimensions

조회 수: 3 (최근 30일)
Mori
Mori 2016년 7월 13일
답변: Andrei Bobrov 2016년 7월 13일
I have 2 cells, A, includes 1*6 cell and each cell has 290 doubles. B, includes 1*11 cell and each cell has 1*6 cell and each cell has 290 doubles.
how I sum A+B by repeating A for each 11 cells ?!

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 13일
A={rand(4,1) rand(4,1)} % Example
B={{rand(4,1) rand(4,1)},{rand(4,1) rand(4,1)},{rand(4,1) rand(4,1)}}
C=cellfun(@(x) cellfun(@(z1,z2) z1+z2,A,x,'un',0),B,'un',0)

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2016년 7월 13일
m = numel(A);
n = numel(B);
C = cell(size(B));
for jj = 1:n
for ii = 1:m
C{jj}{ii} = A{ii} + B{jj}{ii};
end
end

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by