Display the the minimum value

조회 수: 1 (최근 30일)
UTS
UTS 2015년 3월 8일
댓글: Star Strider 2015년 3월 8일
A B
0.025 520
0.027 531
0.029 560
0.031 508
0.033 600
0.035 572
0.037 523
0.039 512
0.041 582
0.043 525
Hi, I am writing a program to determine the value of element A which is corresponding to the minimum value of element B. The answer must be as:
M =
0.031
508
However, the written code
M = min(E,[],2)
gives this answer
M =
0.025
508
Could you please let me know the right code which is able to display the value of element A which is corresponding to smallest value of element B.
Thank you very much

채택된 답변

Star Strider
Star Strider 2015년 3월 8일
This works:
E = [ 0.025 520
0.027 531
0.029 560
0.031 508
0.033 600
0.035 572
0.037 523
0.039 512
0.041 582
0.043 525];
[MinB,Idx] = min(E(:,2));
Result = E(Idx,:)
produces:
Result =
31.0000e-003 508.0000e+000
as desired.
  댓글 수: 2
UTS
UTS 2015년 3월 8일
Thank you very much,
Star Strider
Star Strider 2015년 3월 8일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by