Determine the minimum value excluding zero
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
UTS
el 10 de Mzo. de 2015
Comentada: UTS
el 10 de Mzo. de 2015
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 comentarios
Respuesta aceptada
Andrei Bobrov
el 10 de Mzo. de 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];
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!