How can i use 'sum' for a 'cell array'?

조회 수: 36 (최근 30일)
masoud jiryaei
masoud jiryaei 2019년 5월 7일
댓글: masoud jiryaei 2019년 5월 10일
Hello
i have a cell array that i want to sum the coulmns ;
A={ 1x2 double , 1x2 double
1x2 double , 1x2 double
1x2 double , 1x2 double
1x2 double , 1x2 double }

채택된 답변

KSSV
KSSV 2019년 5월 7일
A = cell(4,2) ;
for i = 1:4
for j = 1:2
A{i,j} = rand(1,2) ;
end
end
B = cellfun(@sum,A)
  댓글 수: 1
masoud jiryaei
masoud jiryaei 2019년 5월 10일
Thank you so much;
It was usefull.

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

추가 답변 (1개)

madhan ravi
madhan ravi 2019년 5월 7일
sum(cat(1,A{:}),2)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by