How to select an maximum value from this matrix?

i have an matrix like this
a=[ 1.7923 179.1685 0.9985
38.6896 186.7030 1.0000
27.9668 191.8023 0.9988
15.1071 188.5679 0.9986
15.3087 173.0626 1.0000];
from this, i need to choose an higher value particularly in 3rd column according to that i want to choose the corespondent row value, like this
example:
b=[38.6896 186.7030 1.0000
15.3087 173.0626 1.0000]
like this i want to get output

 Respuesta aceptada

Star Strider
Star Strider el 3 de Nov. de 2014
This works:
b = a(a(:,3)>=1-1E-8,:)
producing:
b =
38.6896e+000 186.7030e+000 1.0000e+000
15.3087e+000 173.0626e+000 1.0000e+000
The inequality test is to allow for floating-point approximation error.

4 comentarios

if this is like this i'm not getting the correct value it's showing "Empty matrix: 0-by-3"
a=[179.4877 16.9538 0.9989
199.7141 5.5321 0.9979
187.1564 3.3891 0.9983]
i need to get like this
b=[179.4877 16.9538 0.9989];
I’m not quite sure what you want, but if you want the rows with the highest values in ‘a(:,3)’, this will work:
b = a(a(:,3)>=max(a(:,3))-1E-8,:)
Adjust the tolerance on the inequality (here -1E-8) to get the range you want. (The value I chose allows for floating point approximation imprecision.)
Matlab111
Matlab111 el 4 de Nov. de 2014
K thank you.
Star Strider
Star Strider el 4 de Nov. de 2014
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 3 de Nov. de 2014

Comentada:

el 4 de Nov. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by