find N number of min values
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
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
댓글 수: 0
답변 (3개)
  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,:);
댓글 수: 0
  KSSV
      
      
 2016년 5월 31일
        Have a look on the function, this may help. http://in.mathworks.com/matlabcentral/fileexchange/56931-nthbounds-data-n-
댓글 수: 2
  KSSV
      
      
 2016년 5월 31일
        Alternatively you can sort them in ascending order and pick first three..
   [val,pos] = sort(yourVector)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!