MATLAB: using the find function to get indices of a certain value in an array

前端 未结 3 2045
面向向阳花
面向向阳花 2021-01-16 21:28

I have made an array of doubles and when I want to use the find command to search for the indices of specific values in the array, this yields an empty matrix which is not w

3条回答
  •  一向
    一向 (楼主)
    2021-01-16 22:09

    Testing for equality with floating-point numbers is almost always a bad idea. What you probably want to do is test to see which numbers are close enough to the target value:

    peaks = find( abs( y - .8236 ) < .0001 );
    

提交回复
热议问题