LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get less than value in an array & its index

I have a 3 X 1800 array
I would like to search the first Column for a value that is less than a certain number (floating number), then get its index to get the other two values in the other columns.
 
Using search array block you can only use a set number & not less than, any help would be great.
 
Thanks
Shadi
0 Kudos
Message 1 of 6
(10,597 Views)

Index off the column you wnat to seach and feed it into the attached code.  This will give you the indexes where the conditions are true.  Use the index result to index the data from the original array. 

If you just want the minimum values just use Array Min and Max.  It will give you the values and the index to where they are located.

Matt

 

 

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 2 of 6
(10,571 Views)
Use Array Subset to extract the first column. Apply that to the Threshold Array function which returns the first value greater than the threshold and its index (for a 1D array). Use the index as the row index to your original array. Since you want a "less than" search you may need to do some additional manipulation of the data. Also, be cautious if it is possible for the first element of the array to be above the threshold as that may produce unexpected results.

Lynn
0 Kudos
Message 3 of 6
(10,569 Views)

Is there only one number which fits this criteria or are you only searching for a specific number (the smallest, the first instance, etc.)?

Since your array is not very big, the easiest way would probably be going over each element of the array in an auto-indexed while or for loop and checking each element until you find what you want. Other options include sorting the array and using other array functions (like threshold or Max & Min) to find the value, but that depends on what you want to do and is probably not necessary in your case, since your array is small.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(10,568 Views)
Waow... when I saw you thread there was no answer...

It took me 4 minutes to draw a vi to do what I think you're asking for... and you already have 3 answers... Smiley Very Happy

well... here is my contribution, hope this will help you :

for a chosen column in a 2D array compare every value to your threshold, if the value is strictly inferior, add the corresponding index in an array you can then do what ever you want with these index... 😉

there is my vi

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 5 of 6
(10,560 Views)

Thanks all.

The Thershold 1D array is what I was looking for 🙂 No wonder it didn't take you long to answer it :0

thanks a bunch

0 Kudos
Message 6 of 6
(10,547 Views)