getting the mean EXCEPT zero entries

2 vues (au cours des 30 derniers jours)
cgo
cgo le 9 Nov 2018
Commenté : madhan ravi le 9 Nov 2018
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?

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 9 Nov 2018
M=zeros(5);
M(randi(25,10,1))=1:10;
M(M==0)=nan;
mean(M,'omitnan')
  1 commentaire
madhan ravi
madhan ravi le 9 Nov 2018
+1 made it clear

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by