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

63 次查看(过去 30 天)
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 个)

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

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by