How to find the fifth largest value in a matrix
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Please output the fifth largest number from a two-dimensional matrix with more than 5 elements and no repeated values.
%%Problem 2
disp('PROBELM 2')
disp('Random matrix A')
A=rand(3,3)
B=unique(A)
I am stuck after making the matrix. Any help would be appreciated.
0 Commenti
Risposte (2)
madhan ravi
il 5 Feb 2019
2 Commenti
madhan ravi
il 6 Feb 2019
when you specify n as 5 the last number in the result is the fifth largest number
Dong Shim
il 4 Mar 2019
B=unique(A);
% 'unique' also sorts A in the ascending order.
disp(B(end-4))
0 Commenti
Vedere anche
Categorie
Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!