Find Several values closest to zero
Show older comments
Hey all,
I have a simple vector containing my data and wanna find the index of its value closest to zero. At the moment, I am just doing:
zeroIX=dsearchn(mydata,0);
However, this only gives me the very first value. If I have for example a vector like this:
mydata= [1;2;5;0.1;0.1;0.1;2;3]
I omit all the other two values, which are exactly as far away from 0. But in this case for example, I need the index of the middle one. I read through several ideas but haven't figured out a way to find similar values close to zero. Can anyone of you help me?
Thanks in advance and best, Manuel
Accepted Answer
More Answers (1)
Manuel Steinbrecher
on 30 May 2017
0 votes
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!