From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to comparing two 1D array and pull out the mismatched element insert into 2D array

Hi,

Greetings.

I have two 1D arrays and I have a 2D array

first array - { a,b,c,d,e} 

second array - {a,b,z,c,d,e}.

2D array -{name, vendor, type,number

                 abc,        efg ,     a ,   6,

                aaa,        rrrr,       b,     7,

                zzz,        tttt,        c,     6}

I want to pull out that element that is additional in the second array and insert it into 2D array under the type column in the last row. I am not able to find a solution. it would be of great help if anyone helps me in finding a solution.

Thanks in advance!

have a good you'all:)

0 Kudos
Message 1 of 4
(1,953 Views)

1D search add to 2D.png

 

The adding to the 2Darray can be done in a dozen ways. It's not clear to me what exactly should be added, so this solution is just a general one that works.

0 Kudos
Message 2 of 4
(1,932 Views)

Thank you so much for the reply:) 

The z element which is present in the second array should be added to the type column leaving other columns blank.

name  vendo type numb

aaa     bbb      a    6

cccc    rrr        b    7

eee     zzz      c     8

www    qqq     d     5

uuu      iiii        e     9

                       z          

similar to this I have again 2 - 1D array so I should search in the similar manner and find that additional element and add it to the 2D array

name                    vendo  type  numb

aaa                        bbb      a       6

cccc                        rrr        b       7

eee                         zzz      c       8

www                       qqq      d       5

uuu                          iiii        e      9

new-element                       z   

0 Kudos
Message 3 of 4
(1,924 Views)

@DeepJames wrote:

The z element which is present in the second array should be added to the type column leaving other columns blank.


Simply remove the "??" from the string, you'll get empty strings.

 

If the input array has the data (I only copied the titles), what I've posted does this.

 


@DeepJames wrote:

similar to this I have again 2 - 1D array so I should search in the similar manner and find that additional element and add it to the 2D array

name                    vendo  type  numb

aaa                        bbb      a       6

cccc                        rrr        b       7

eee                         zzz      c       8

www                       qqq      d       5

uuu                          iiii        e      9

new-element                       z   


Not sure what you mean.

 

You also have 1D arrays for the name column? I'd hope the added element in that array has the same index as in the type array.  So you can simply use the index to get the new name:

 

1D search add to 2D (2).png

0 Kudos
Message 4 of 4
(1,912 Views)