03-03-2014 10:51 AM
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?
Solved! Go to Solution.
03-03-2014 10:56 AM
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.)
03-04-2014 03:05 AM
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...
03-04-2014 03:19 AM
@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).
03-20-2014 02:26 AM
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...