LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to index occurrences in the array

Solved!
Go to solution

Hi Is there a way how we can index each occurrence in the array?

It seems that search ID Array  is once and I cannot figure out how to do it.

 

Please advise

Thanks in advance

 Clement

0 Kudos
Message 1 of 10
(2,647 Views)

Clement,

 

Occurrence of what?  If you want to do something with each element of an array, use a for loop with auto-indexing enabled.  You can put Search 1D Array in a loop with the start index connected via a shift register.

 

Lynn

0 Kudos
Message 2 of 10
(2,645 Views)

I tried already but it does not work and I can't figure it out.

It does not work right way

 

See the pic below. How do we get index for each occreeneces in the array.

 

 

index occurrences in the array.JPG

0 Kudos
Message 3 of 10
(2,641 Views)

Actually,  after I sort ID arr_input. that's how I get result of arr_index

 

 regards

Clement

0 Kudos
Message 4 of 10
(2,640 Views)

Clement,

 

So you want the index in arr_input of the element with the value 0, then with the value 5, and so on?  Is that what you mean by "occurrence"? Do you want the first "0" or all of them?  Do you need both the value and the index?  How do you want the results displayed?  What is the data represenstation - integer or double?

 

Lynn

0 Kudos
Message 5 of 10
(2,636 Views)
Solution
Accepted by topic author astroboy

Do you need only the indexes that matches the search element like this?

 

Get index.png

 

Get index FP.PNG

-----

The best solution is the one you find it by yourself
0 Kudos
Message 6 of 10
(2,629 Views)

Hi P Anand,

 Thanks  which array function do you use. I can't  tell from the look.

I tried every array function but it dies not work. I am using lab v7.1

 Clement

0 Kudos
Message 7 of 10
(2,625 Views)

I have used only build array function inside the for loop with a shift register. I treid the same with array functions but it didn't really work. Is that what you wanted to achieve?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 8 of 10
(2,623 Views)

Hi Thanks it nearly works but it is better than nothing. at least i know one of the function before proceeding .

Thanks

 

regards

Clement

0 Kudos
Message 9 of 10
(2,616 Views)
In general you should really be using a Case Structure instead of Select. The only thing harder on your CPU than using Build Array inside a loop is to be doing allocations unnecessarily. With a Case Structure at least you only append to the array when necessary.
0 Kudos
Message 10 of 10
(2,610 Views)