Finding the mean value for five maximum number in matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ali Noori
le 20 Jan 2015
Commenté : Star Strider
le 20 Jan 2015
Hi guys, I have (1*9) matrix below, I 'd like to calculate mean value for max 5 number in this matrix can anyone help me?
Regards
0 commentaires
Réponse acceptée
Star Strider
le 20 Jan 2015
This works:
x = [20 19 1 20 21 22 4 2 1];
xs = sort(x,'descend');
max5mean = mean(xs(1:5))
produces:
max5mean =
20.4
2 commentaires
Plus de réponses (1)
Chad Greene
le 20 Jan 2015
Modifié(e) : Chad Greene
le 20 Jan 2015
X_sorted = sort(X);
mean5 = mean(X_sorted(1:5),'descend');
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!