필터 지우기
필터 지우기

Calculating mean in array

조회 수: 2 (최근 30일)
Royvg94
Royvg94 2015년 9월 18일
댓글: Adam 2015년 9월 18일
I got an 69 x 1 array, which contains 12 x 2 and some 13 x 2 matrices. I want to calculate the mean of the 2nd column of every matrix in the array. And if possible, get the results to show in an 69 x 1 matrix.
Thanks for the help!

채택된 답변

Adam
Adam 2015년 9월 18일
cellfun( @(x) mean(x(:,2)), myArray )
should work, assuming you mean you have a cell array which is the only type of array that would fit your description.
  댓글 수: 2
Royvg94
Royvg94 2015년 9월 18일
what do i have to fill in on the x?
Adam
Adam 2015년 9월 18일
'myArray' should be replaced by whatever you have named your 69x1 array.
'x' is just a placeholder. Usually I name my variables more verbosely, but in cellfun I often just use 'x' as a placeholder rather than giving it a longer name. You can call it what you like so long as you use the same name in both places 'x' appears.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by