How to get the mean of a cell array of matrices

조회 수: 2 (최근 30일)
YH
YH 2019년 12월 10일
댓글: YH 2019년 12월 10일
Hallo,
I have a cell array (99*1000)
each cell for example test {1,1 } looks like this 1*4 double : [-1.7, 0.8,0.276, -0.2]
I want the mean of each column and for the entir cell array so that at the end will have a cell array (1*1000) with each cell: [mean of the first column, mean of the second column, mean of the third column, mean of the fourth column]
I hope some one could help, I know it a little bit complicated to explain exactly what I want to I attached the cell array as mat file.
I tried many things with cellfun and arrayfun but it seems that I am missing something because I couldn't reach the form that i really want.
Any tipps would be really helpful!
thanks in advanced!

채택된 답변

Stephen23
Stephen23 2019년 12월 10일
편집: Stephen23 2019년 12월 10일
>> out = permute(num2cell(mean(cell2mat(permute(test,[1,3,2])),1),2),[1,3,2]);
Checking:
>> size(out)
ans =
1 1000
>> out{1}
ans =
-1.346736 0.326463 0.236545 -0.045276
>> mean(vertcat(test{:,1}),1)
ans =
-1.346736 0.326463 0.236545 -0.045276
  댓글 수: 1
YH
YH 2019년 12월 10일
Stephen Cobeldick: thank you so much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by