From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search a value in an array

Solved!
Go to solution

Hi, I'm trying to find the index of a value in an array, I know there is a VI called "search in a 1D array" but there is my problem : Let's say I'm searching the value 25, and in my measurement serie, there is like 24.998 and 25.001 but no 25, this VI won't find the value 25 even though it went pretty close, so basically I'm trying to inplant a tolerance system which will make able to find with +-3 or 4 precision on the index, do somebody got something for that ? 

 

Thanks for your time 

0 Kudos
Message 1 of 5
(2,351 Views)
Solution
Accepted by topic author Dotheflopguy

I wrote this for a similar job but it could be used for your application.  Simply use the attached vi in a loop to check for 'In Range' and return the loop index of the first occurance.

 

Hope this helps

 

Ken

 

 

Message 2 of 5
(2,336 Views)

Thanks for your help, I also found an other solution : I converted the array in I32 (because it was fill in with DBL), so here as soon as I get a 25.xxxxx, it take 25 and the VI find my value 🙂

Your solution might more elegant by the way.

0 Kudos
Message 3 of 5
(2,331 Views)

Warning - converting the array to I32 will return the value if it is in the range 24.500001 to 25.499999  i.e ± 0.5 only hence you have no control over the precision of your search.

 

By the way, 'Round to nearest' does the same as convert to I32 but keeps it DBL

 

Regards

 

Ken 

0 Kudos
Message 4 of 5
(2,323 Views)

No worry I don't expect that much precision and I put some correction term (+-0.5) to be precise in my detection (It does not affect my data and solve my problems) 😉

 

My goal was to choose a min and a max value, then to detect this 2 values to create an interval, and delete all data out that interval (dynamically), to make a calculation only on these data, but it works now 🙂 

0 Kudos
Message 5 of 5
(2,299 Views)