필터 지우기
필터 지우기

two dimension array mean and deviation calculation

조회 수: 2 (최근 30일)
wen
wen 2014년 11월 4일
댓글: wen 2014년 11월 4일
Hi, I have a two dimension array like X = normrnd([1 4;2 2;3 6;4 4;5 7;6 4;7 9;8 4;9 8;10 4],1); and I want to calculate the mean and standard deviation after several rounds. For example, I want to generate the array for 5 times, and I'd like to see the mean and standard deviation of each element, how can I do that?
Many thanks!

채택된 답변

Mikhail
Mikhail 2014년 11월 4일
There are a lot of ways to do that. I would generate 3D array, where the third dimension will be of the size = # of rounds (5);
So you will have array X(m,n,r), where r=1:5 (if number of rounds is 5).
Now, use mean and stddiv with second argument 3:
MeanX=mean(X,3); StddivX=stddiv(X,3);
This will calculate mean and stddiv through 3rd dimension. As a result you obtain two 2D arrays, what you were asking.
  댓글 수: 2
Mikhail
Mikhail 2014년 11월 4일
So X(:,:,1) is your first 2D array, X(:,:,5) - last, etc.
wen
wen 2014년 11월 4일
thanks a lot!

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

추가 답변 (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