필터 지우기
필터 지우기

How to sum two cells element by element?

조회 수: 14 (최근 30일)
M
M 2023년 7월 19일
편집: Matt J 2023년 7월 19일
How to sum two cells element by element by one shot?
if there is a cell A and its size(6,9) and cell B and its size(6,9).
how to do the sumation of A and B element by element?
for example:
sum A{1,1} and B(1,1}
sum A{1,2} and B(1,2} and so on...
and store all the results in another cell

채택된 답변

Matt J
Matt J 2023년 7월 19일
편집: Matt J 2023년 7월 19일
One way,
A={1,2}, B={10,20},
A = 1×2 cell array
{[1]} {[2]}
B = 1×2 cell array
{[10]} {[20]}
C=cellfun(@plus, A,B,'uni',0)
C = 1×2 cell array
{[11]} {[22]}
  댓글 수: 1
Matt J
Matt J 2023년 7월 19일
편집: Matt J 2023년 7월 19일
Although, it is of course ill-advised to sum cell array contents if they can instead be organized into numerical arrays.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by