Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a list from which I want to extract only the values beginning from where b (from {a,b}) is the closest to zero. For example: I want extract data={{2, -0.036704}, {56.7499, 0.95489}, {73.7349, 0.73489}, {2, -0.237504}} from the following list: list={{1, 0.67342}, {77.7499, -0.93489},{6.73448, 0.056704},{2, -0.036704}, {56.7499, 0.95489}, {73.7349, 0.73489}, {2, -0.237504}}

Thanks in advance

share|improve this question
1  
Look up Nearestin the docs. –  Yves Klett Nov 10 '13 at 18:22

1 Answer 1

up vote 0 down vote accepted

One way is to find the index ind where the minimum occurs, and then take all the remaining elements of the list:

ind = First@Ordering[First@Abs[Rest[Transpose[list]]]];
list[[ind ;;]]
{{2, -0.036704}, {56.7499, 0.95489}, {73.7349, 0.73489}, {2, -0.237504}}
share|improve this answer
    
For long lists, the following may be faster ind = First@ Ordering[Abs@ list[[All, 2]], 1] –  user8074 Nov 10 '13 at 19:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.