LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search 1D find element in which index

Solved!
Go to solution

Hi all

  I have a demo want to search in 1D find element in which index,from numeric 1-10 when fill in numeric 3,5,6,7,10 can do it right excepted fill in numeric 1,2,4,8,9.What cause for the issue? Thanks for all prompt reply.

snapshot.png

0 Kudos
Message 1 of 3
(2,352 Views)
Solution
Accepted by topic author Sam.Huang

You are dealing with floating point values, so all equal comparisons are questionable. For example if ampltitude=2, the second peak has a value of 1.99999999999999956000 (if you display all decimal digits!) which is arguably not the same as 2. All Y values are the result of complicated calculations and will typically not fall into place unless you are very lucky.

 

Also:

  • You don't need any local variables here. Makes no sense.
  • You can stop the loop once the result is -1. No need to spin it an additional ~1000x times.
  • Here's your code using more reasonable techniques (same result!)

altenbach_0-1636079743649.png

 

Message 2 of 3
(2,338 Views)

Thanks for you,I got it.

0 Kudos
Message 3 of 3
(2,277 Views)