Determine the minimum value excluding zero

23 ビュー (過去 30 日間)
UTS
UTS 2015 年 3 月 10 日
コメント済み: UTS 2015 年 3 月 10 日
A B
0.025 520
0.027 531
0.029 560
0.031 508
0.033 000
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. this value is not equal to zero [excluding zero]. The answer must be as:
M =
0.031
508
However, the written code
[MinB,Idx] = min(E(:,2)); Result = E(Idx,:)
gives this answer
M =
0.033
000
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 but it is not equal to zero
Thank you very much

採用された回答

Andrei Bobrov
Andrei Bobrov 2015 年 3 月 10 日
A= [0.025 520
0.027 531
0.029 560
0.031 508
0.033 000
0.035 572
0.037 523
0.039 512
0.041 582
0.043 525]
ii = A(:,2) > 0;
A2 = A(ii,:);
[M,i2] = min(A2(:,2));
out = [A2(i2,1),M];
  1 件のコメント
UTS
UTS 2015 年 3 月 10 日
Thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by