LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with 2D array

Solved!
Go to solution

Hi All,

I am working with a 2D array which stores numeric values. Let me explain my problem with an example.

consider a 2D array as shown in the attached image(input.png). the elements in the 2nd row are already present

in the 1st row. How can i obtain a new 2d array in which the rows, which are already a subset of some other

row, are not present i.e., each row has unique elements only.(output.png)

 

Thank you for the help.

Regards

Aveo 

Download All
0 Kudos
Message 1 of 16
(3,189 Views)

Are the non-duplicate element values always increasing in memory order? That would simplify certain things.

 

I would (1) reshape to a 1D array, (2) remove all duplicates, (3) then reshape back to a 2D array of the original size.

 

 

0 Kudos
Message 2 of 16
(3,178 Views)

 

Hi,

Thank you for the quick reply.

YES, the non-duplicate element values always increase in memory order.

However the 2d array could be like this also:      1  2  3  4  5  6  8  9

                                                                      2  5  6  8  0  0  0  0

                                                                      5  8  0  0  0  0  0  0 

                                                                      7  0  0  0  0  0  0  0

 

Regards

Aveo                               

0 Kudos
Message 3 of 16
(3,163 Views)

@aveo wrote:

 

YES, the non-duplicate element values always increase in memory order.

However the 2d array could be like this also:      1  2  3  4  5  6  8  9

                                                                      2  5  6  8  0  0  0  0

                                                                      5  8  0  0  0  0  0  0 

                                                                      7  0  0  0  0  0  0  0                        


Well, in this example they don't increase in memory order (e.g. 8 occurs before the first 7). Do you want them sorted in the output array in this case or in the original order of first occurrence. (It does not help if you describe a special case, but then fail to show what the desired output would be ;))

 

If you want the output sorted, do bascally what I suggested above.

 

Remove all duplicate elements or elements that are zero. (here are some ways to do it, some are much more efficient ;)). Of course you would need to add code to also remove zeroes. Should be trivial to change. Good luck. 😄

 

0 Kudos
Message 4 of 16
(3,139 Views)

Thanks for the suggestions. 🙂 

I will implement them and post it here.

Regards

Aveo 

0 Kudos
Message 5 of 16
(3,131 Views)

Hi Altenbach,

Thanks for your suggestions.

I have created a vi (Find_Overlapping_Rows.vi) that does what i require, however in a different way.

can you suggest any more improvements in it?

Thanks.

Regards

Aveo

0 Kudos
Message 6 of 16
(3,078 Views)

Put some typical numbers in the input array, make the current values default, save and attach the toplevel VI once more.

 

... and yes, this looks way too complicated. Can there be negative values too?

0 Kudos
Message 7 of 16
(3,058 Views)

Here's what I had in mind....

 

 

0 Kudos
Message 8 of 16
(3,049 Views)

Hi Altenbach,

I am attaching the vi again with an initialized array. 

I put the same array in your vi and the results are different. 

If you will take a look at the array the 6th row(starting from 0) has 10 and is not a subset of any other row.

However in Find_Overlapping_Rows_MODCA.vi it is not coming as i want it.

And there cannot be negative values. 

Thanks.

Regards

Aveo

 

0 Kudos
Message 9 of 16
(3,023 Views)

aveo wrote:

However in Find_Overlapping_Rows_MODCA.vi it is not coming as i want it.


Then you need to define better what you want. There are millions of possible results that are different from what I did, so we cannot narrow it down at all given the vague information. What is the exact result you want from your VI when run with the current default input data?

 

Maybe you should manually fill the output array with the exepcted result and also make it the default.

0 Kudos
Message 10 of 16
(3,014 Views)