필터 지우기
필터 지우기

Extracting a value from one column to its corresponding column?

조회 수: 1 (최근 30일)
Yasir Ali
Yasir Ali 2016년 12월 15일
편집: Stephen23 2016년 12월 15일
Hi, I have a matrix (say 7 x 2). first column contains id and second column contains scores. I want to write a code to extract id from first column which is corresponding to minimum score in second column?
M = 1 363.026
11 330.302
24 289.07
55 240.3120
59 188.209
79 162.937
87 108.104
I know 87 has lowest score. But how to write effective code so that for larger matrix it should fetch id corresponding to lowest score? Thanks

채택된 답변

KSSV
KSSV 2016년 12월 15일
편집: KSSV 2016년 12월 15일
[val,idx] = min(M(:,2)) ; % get minimum value and position from scores
id = M(idx,1) ; % get the id of the minimum score
  댓글 수: 1
Yasir Ali
Yasir Ali 2016년 12월 15일
Thank you so much for this helpful answer. Worked fine. Really appreciated.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by