필터 지우기
필터 지우기

find N number of min values

조회 수: 2 (최근 30일)
Panayiotis Christodoulou
Panayiotis Christodoulou 2016년 5월 31일
편집: Andrei Bobrov 2016년 5월 31일
Hi there,
I have a dataset:
10 11 5 6 23 4 1 3 98 56
I want to find the 3 smallest values that exist in the dataset without replacing data from the original dataset as well their indices.
final result would be: Row,Value 7,1 8,3 6,4

답변 (3개)

Andrei Bobrov
Andrei Bobrov 2016년 5월 31일
편집: Andrei Bobrov 2016년 5월 31일
s = [10
11
1
5
6
3
23
4
1
3
98
56];
[a,b] = unique(s,'first');
out = [b,a];
out = out(1:3,:);

KSSV
KSSV 2016년 5월 31일
  댓글 수: 2
Panayiotis Christodoulou
Panayiotis Christodoulou 2016년 5월 31일
hi there,
i have a 10x1 matrix array and i want to find the 3 min values not just the 1.
KSSV
KSSV 2016년 5월 31일
Read the documentation of the function.....that can be done....

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


KSSV
KSSV 2016년 5월 31일
Alternatively you can sort them in ascending order and pick first three..
[val,pos] = sort(yourVector)

카테고리

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