calculate mean each element in each cell in a cell array
2 views (last 30 days)
Show older comments
hi,
I have a cell
A = {[1,2,3, 4] [5,6,7,8] [9,10,11,12] ; [4,3,2,1] [8,7,6,5] [12,11,10,9]}.
I wanted to average each element. the result cell array will be B = {[2.5 2.5 2.5 2.5] [6.5 6.5 6.5 6.5] [10.5 10.5 10.5 10.5]}.
Please suggest. thanks!
0 Comments
Accepted Answer
David Hill
on 30 Aug 2022
A = {[1,2,3, 4] [5,6,7,8] [9,10,11,12] ; [4,3,2,1] [8,7,6,5] [12,11,10,9]};
B=mat2cell(mean(cell2mat(A)),1,length(A{1,1})*ones(1,size(A,2)))
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!