필터 지우기
필터 지우기

finding the 10 lowest values

조회 수: 23 (최근 30일)
Adam
Adam 2011년 10월 13일
댓글: Adam 2017년 2월 23일
I have a matrix with a lot of data, and i want to find the 10 lowest values of a specific collum.
Does anybody know how to do that?
i was thinking about using the function min() but it does not allow me to select a specific collum, or finding more than the one value which is the lowest.

채택된 답변

Artik Crazy
Artik Crazy 2011년 10월 13일
  • Let's say you have a matrix of 10x10:
x=rand (10,10);
  • Sort it by the columns in ascending order:
y=sort (x,1, 'ascend')
*Now take the 5 first rows - these are the lowest values in every column:
z=y(1:5, :)

추가 답변 (2개)

the cyclist
the cyclist 2011년 10월 13일
First 10 values of "sorted_x" is what you want.
A = rand(100,10);
columnToSort = 7;
[sorted_x, index] = sort(A(:,columnToSort),'ascend');

Marc
Marc 2017년 2월 23일
But if I want the indexes of these 10 values? Should I sort to find the values and then "find" these values in the matrix?
Is there a more elegant way?
  댓글 수: 1
Adam
Adam 2017년 2월 23일
the cyclist gave an answer that also returns indices. You can just feed these directly into your array.

댓글을 달려면 로그인하십시오.

카테고리

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