LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search 1d array for a value

Solved!
Go to solution

Hi all,

I have an 1d array of numbers which ranges from 255 to 0, i want to search for an first element which is less than 100 and retrieve the index.

Can anybody help me how to go about it.

 

 

 

Regards,
KM
0 Kudos
Message 1 of 10
(6,980 Views)

kamasani a écrit :

Hi all,

I have an 1d array of numbers which ranges from 255 to 0, i want to search for an first element which is less than 100 and retrieve the index.

Can anybody help me how to go about it.

 


This is an easy task, what have you tried?

 

hint: autoindex FOR loop, compare element with 100, if less then stop loop and index of loop is the index of element.

 

Have you looked at these free introduction class to LabVIEW:

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction

 

Ben64

Message 2 of 10
(6,922 Views)

Hi kamasani,

 

You can use for loop to do this program.

 

I hope it's helpful for you.

 

Tunnel mode -> Conditional. It means if TRUE will build ARRAY. 

 

So input array size is not equal to output array size.

 

For example, Input array is [0 200 50 150]. Only 0 and 50 less than 100.

 

Output Array is [0 2].(Index of Array)

 

Search and Retrieve Index (Array).png

 

 

 

Certified LabVIEW Developer
0 Kudos
Message 3 of 10
(6,913 Views)

Hi Ben64,

Thanks for the hint, it worked out. 

I need a little more help to do the following:

I want to repeat this for all the column indeces attached to the post.

  • I want to extract corresponding columns
  • Find the Row index

Please suggest me how to go about it.

Regards,
KM
Download All
0 Kudos
Message 4 of 10
(6,900 Views)
Solution
Accepted by topic author KevinKM

Use the same ideas.  Throw one column into the array at a time.  Search.  Repeat.

 

The most "complex" part of this program is interfacing with the excel spreadsheet.

0 Kudos
Message 5 of 10
(6,877 Views)
You do not need to index through the array. All LabVIEW low-level comparison functions are polymorphic. Take a less than comparitor and wire the input array to the top input terminal. To the bottom input wire a scalar numeric constant containing 100. The output is a boolean array of comparisons. Use the search 1d array node to search this array for the first true. The output is the index.

Done...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 6 of 10
(6,822 Views)

Hi all,

Thanks for you replies,

I have a 2d array of size, 3969 X 600. I need to extract 1000  columns at once and search for an element less than 100 for each columns. 

The 2d array size varies for different images. So as the number of columns. 

I need your suggestions folks,

 

 

 

Regards,
KM
0 Kudos
Message 7 of 10
(6,806 Views)

Take the Array.  Subtract 100.  Do a comparison Less than Zero.

 

Iterate through the array row by row.  Do AND Array Elements to find a row where every column is Less than 0.

Message 8 of 10
(6,797 Views)

Whoa! There are tutorials online? I had no idea! If only people would reference them more often!

0 Kudos
Message 9 of 10
(4,704 Views)

@stevenette wrote:

Whoa! There are tutorials online? I had no idea! If only people would reference them more often!


Was even true in early 2015 ... 😄

0 Kudos
Message 10 of 10
(4,696 Views)