11-21-2011 05:10 PM
I have 2d array like this one:
1 2 3 4 5 0
5 6 2 4 7 2
8 3 6 0 9 4
5 6 7 7 3 2
And I need to find elements which appears only once in this array
In this case 8 and 9
I also need position of this elements (row and column)
Numbers are integers
I tried to reshape array and use find element but no results.
Solved! Go to Solution.
11-21-2011 08:13 PM
11-22-2011 07:14 AM
I tried to find indexes of each elements:
and later i wanted to get element that has only one index
but i think now that this is a bad aproach for this problem
11-22-2011 08:13 AM
Hi pawhan11,
you can create a histogram from your data, there are functions in LabVIEW to do it, and a lot more around here in the forum. If you have the histogram, then you can search the elements with the value "1". The last step is to search them again in your array to get the position.
Hope it helps.
Mike
11-22-2011 09:20 AM
Your best bet is to reshape to a 1D array to do your seaching and use "Quotient & Remainder" to convert the location (index) in the 1D array back to the index in the 2D array. Use "Array Size" to get the number of rows and cols of the 2D array.
The Histogram only works on 1D arrays.
Or reshape to a 1D array. For each digit (0-9) use "Search 1D Array" twice. If the first "Search" finds a match (not= -1), use the offset to start the 2nd search past the index of the 1st find. If 2nd "Search" does return a -1 then it occurs ONE and only ONE time
Use the index from the first "Search" to calculate the index ("Quotient & Remainder") Row and Col in the 2D array.
11-22-2011 10:18 AM
@Omar II wrote:
Or reshape to a 1D array. For each digit (0-9) use "Search 1D Array" twice. If the first "Search" finds a match (not= -1), use the offset to start the 2nd search past the index of the 1st find. If 2nd "Search" does return a -1 then it occurs ONE and only ONE time
Use the index from the first "Search" to calculate the index ("Quotient & Remainder") Row and Col in the 2D array.
So obvious solution .....
Big hanks
11-22-2011 11:14 AM - edited 11-22-2011 11:16 AM
Here's a solution that should work for you. Sorry, ignore the Abort.zip.
11-22-2011 02:24 PM - edited 11-22-2011 02:58 PM
From the original description, is is not absolutely clear if a small array of all possible values is provided. If is is not, here's a quick draft for random integer ranges. I also included a table where all unique values are highlighted with a different background color. Just to give you some ideas.... 😉
11-22-2011 05:18 PM
@altenbach wrote:
From the original description, is is not absolutely clear if a small array of all possible values is provided. If is is not, here's a quick draft for random integer ranges. I also included a table where all unique values are highlighted with a different background color. Just to give you some ideas.... 😉
Thanks 🙂
Just to be 100% sure, one small question:
[-2 -2] allows You to modify all elements of table at once??
11-22-2011 05:31 PM
altenbach wrote
From the original description, is is not absolutely clear if a small array of all possible values is provided.
From the first post I too though the same thing. But from his 2nd post with his code posted, he is providing a search array with digits 0-9.
I teach a LabVIEW class and one of the assignments I give the students is a sudoku solver (looking for digits 1-9).
So along some of the solutions for that.