Finding the mean value for five maximum number in matrix
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Noori
am 20 Jan. 2015
Kommentiert: Star Strider
am 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/146854/image.png)
0 Kommentare
Akzeptierte Antwort
Star Strider
am 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 Kommentare
Weitere Antworten (1)
Chad Greene
am 20 Jan. 2015
Bearbeitet: Chad Greene
am 20 Jan. 2015
X_sorted = sort(X);
mean5 = mean(X_sorted(1:5),'descend');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!