adding cells of two arrays
조회 수: 5 (최근 30일)
이전 댓글 표시
답변 (2개)
Star Strider
2023년 3월 1일
Perhaps something like this —
A = {[10,9,13,21,18] [9,9,11,18,18]};
B = {[11,10,12,20,19] [10,9,13,21,18]};
C = cellfun(@(x,y)x+y, A,B, 'Unif',0)
This assumes that ‘A’ and ‘B’ are cell arrays, as depicted here.
.
Sumera Zem
2023년 3월 1일
A = {[10,9,13,21,18],[9,9,11,18,18]};
B = {[11,10,12,20,19],[10,9,13,21,18]};
C = cell(size(A)); % initialize C with the same size as A
for i = 1:numel(A)
C{i} = A{i} + B{i}; % add the corresponding arrays in A and B
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!