getting the mean EXCEPT zero entries

조회 수: 3 (최근 30일)
cgo
cgo 2018년 11월 9일
댓글: madhan ravi 2018년 11월 9일
I have a matrix, M = [zeros(10,10); 1 , 2 , 3 ,4 ,5,6,7,8,9,10];
I want to get the mean of each column, except the zero terms. How do I do this?

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2018년 11월 9일
M=zeros(5);
M(randi(25,10,1))=1:10;
M(M==0)=nan;
mean(M,'omitnan')

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by