How to find the fifth largest value in a matrix

4 ビュー (過去 30 日間)
Sarah Hicks
Sarah Hicks 2019 年 2 月 5 日
回答済み: Dong Shim 2019 年 3 月 4 日
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.

回答 (2 件)

madhan ravi
madhan ravi 2019 年 2 月 5 日
  2 件のコメント
Sarah Hicks
Sarah Hicks 2019 年 2 月 6 日
I am still confused on how to find, specifically, the fifth largest number.
madhan ravi
madhan ravi 2019 年 2 月 6 日
when you specify n as 5 the last number in the result is the fifth largest number

サインインしてコメントする。


Dong Shim
Dong Shim 2019 年 3 月 4 日
B=unique(A);
% 'unique' also sorts A in the ascending order.
disp(B(end-4))

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by