LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Index from matrix

Solved!
Go to solution

I'm using the Read From Spreadsheet File VI for reading a textfile which contains a 52x49 matrix with numbers from 1-100. I want to find the index of the rows and columns where the number 5 are located. How can I do this?

0 Kudos
Message 1 of 5
(2,441 Views)

You can autoindex your 2D array on a stack of two FOR loops, then conditionally build an array of indices (in a shift register or conditional tunnel). See how far you get. I assume you are dealing with integers here.

 

(You could also go a little fancier using "search 1D array" on each row, but that would just make things more complicated.)

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

Yes you're correct I'm dealing with integers. What if a row contains multiplers of the wanted integer? The "search 1D array" stops searching for the desired element as soon as the first element is found? I'm pretty much stuck here, this is how far I've come... 

0 Kudos
Message 3 of 5
(2,395 Views)
Solution
Accepted by topic author hannesostergren

@hannesostergren wrote:

The "search 1D array" stops searching for the desired element as soon as the first element is found?


That's why I said it would be a little more complicated. You need to continue searching from each found index until the end is reached.

It is simpler to simply iterate through all elements as follows (change the enabled case to use you file).

 

 

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

Thanks for the help! 

 

I've got into a new problem that you might can help me with...

In my previous VI the input for the Case Structure is the the 2D array I want to read specified elements from and the output is the coordinates/index where the elements are located in the array. 

 

This time I read the elements of the array as Strings and not Integers. Now I want to able to choose, as an input for the case structure, which element I want the coordinates/index for in the array. As an example I want to find where the string "A" are located in the 2D array.

 

So this time it should be two inputs; the "element" I want to find the coordinates/index for and ofcourse the 2D array where the element are located in. How can I do this? I don't manage it to work properly...

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