Determine the minimum value excluding zero
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 10 Mär. 2015
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];
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!