LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to take specific values from a 2d array

Solved!
Go to solution

hi all

i have a 10X10 2d array of reasult. for instance:

1    2    3    4 

5    6    7    8 

9  10   11  12

 

and i want a specific values from the array/ say 1,3,7 and 10 (there is no given pattern to work with..)

I used the IndexArray but because it's about 20 values, it's hell to change and hell to debug...

 

Is there any more elegant way to do this?

thanx!

 

(this is one great forum, it's my first time posting a question but i've been following you for a while!)

0 Kudos
Message 1 of 6
(2,911 Views)

Assuming you know the values you are looking for, index the 2d array using a for loop and search for the specific value/s using search 1D array node.

I've to add that your question is a bit vague and may be barking up the wrong tree! It would help a great deal if you posted a snippet/vi of your current implementation.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 6
(2,902 Views)

thanx for replying!

i currently have problem with the network on my labview computer so i cant upload pics or so..

 

i'll further explain:

the 2d array is a result of set of tests from which i want to take the results that are important for me.

i dont know the values for each test but the locations are constant.

 

the problem is that the IndexArray is too hard to read or change because of the quantity of the tests

 

 thanx!

0 Kudos
Message 3 of 6
(2,894 Views)

OK, so if I understand this currectly, you have a 2D array with 100 elements and you want to pick out 20 values whose index locations are constant.

 

"take the result" is a poorly defined description. What are the exact indices you want? Is there a regular pattern?

 

How do you want the output?

  • One at a time in a specific order?
  • As a 1D array in a specific order?
  • as a 2D array with all other elements zeroed?

@sebastiant wrote:

the problem is that the IndexArray is too hard to read or change because of the quantity of the tests


I don't understand. What are you "reading"? What is a "test"? Why is it "hard"?

0 Kudos
Message 4 of 6
(2,889 Views)
Solution
Accepted by topic author sebastiant

You can drag the index array function down, creating something that looks like this:

temp.png

That will allow you to output multiple elements from the same array simultaneously, by putting in each separate set of indices. If you want to make it easier to debug, make the indices inputs, name them effectively, and group them in x,y pairs. 

 

You could also make a boolean array and use that to select the indices you want. This makes more sense if your indices need to be selected graphically.

VI snippet array indexing.png

Colden
Message 5 of 6
(2,864 Views)

wow!

colden R im in debt for you for all eternity!!

 

the second solution is great and exactly what i needed!

 

thank you very much!

0 Kudos
Message 6 of 6
(2,851 Views)