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 CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by