# Documentation for mean function

조회 수: 2 (최근 30일)
L'O.G. 2022년 7월 11일
댓글: Stephen23 2022년 7월 11일
I have a 200×1 cell array where each element is {130×1 double}. I want the mean for all the first elements in the 200 cells, all the second elements, all the third elements, and so on. So in the end the vector should be 130 x 1. This seems to do the trick:
mean([C{:}],2)
But from what I understand of the documentation for mean, the 2 indicates that the average is being taken along each row. But isn't each row the 130 x 1 cell array? I don't want the average of those 130 numbers as I mentioned. Am I just misunderstanding the documentation?
##### 댓글 수: 2없음 표시없음 숨기기
Torsten 2022년 7월 11일
편집: Torsten 2022년 7월 11일
C{1} = [4;5;6];
C{2} = [7;8;9];
C{:}
ans = 3×1
4 5 6
ans = 3×1
7 8 9
[C{:}]
ans = 3×2
4 7 5 8 6 9
mean([C{:}],2)
ans = 3×1
5.5000 6.5000 7.5000
Stephen23 2022년 7월 11일

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

### 채택된 답변

Steven Lord 2022년 7월 11일
You're not taking the mean of the cell array. That construct, [C{:}], creates a comma-separated list from the cell array and concatenates the elements of the list together into a numeric array. See the Concatenation section on that documentation page I linked above for an illustration.
So you're passing a numeric array into mean along with a dimension input. For a picture that may help clarify how the dim input is used, see the description of the dim input argument on the mean documentation page.
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
L'O.G. 2022년 7월 11일

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

### 카테고리

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

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by