Finding 4 closest values to a value in an array
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
채택된 답변
  Sindar
      
 2020년 9월 28일
        use mink
[~,idx] = mink(abs(data-find_point),5);
data(idx)
댓글 수: 2
  Sindar
      
 2020년 9월 29일
				You'd play around with (data-find_point) without the abs(). Algorithm something like:
- separate data into values equal to, larger than, smaller than find_point
 - keep all equal to
 - find smallest 2 positive error
 - find largest 2 negative error
 
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!