Compare Two Number Arrays

  • Follow


Hi,

I have two arrays:

date_array1 = [ 20101201; 20091201; 20091101; 20100101 ];

date_array2 = [ 20081201; 20101201; 20091201; 20061201; 20100101 ];

I basically want to compare the two arrays and get only the elements of second array date_array2 that are not present in date_array1.

So in the above example I want to get a result of:
20081201
20061201

Either of the arrays may be larger than the other. In my actual problem both the arrays are huge, so I was wondering if there was a smart efficient way to do it.

Thanks in advance.
0
Reply jay 8/30/2010 5:15:19 PM

"jay jay" <jay.oberoi@yahoo.com> wrote in message <i5gov7$d8s$1@fred.mathworks.com>...
> Hi,
> 
> I have two arrays:
> 
> date_array1 = [ 20101201; 20091201; 20091101; 20100101 ];
> 
> date_array2 = [ 20081201; 20101201; 20091201; 20061201; 20100101 ];
> 
> I basically want to compare the two arrays and get only the elements of second array date_array2 that are not present in date_array1.
> 
> So in the above example I want to get a result of:
> 20081201
> 20061201
> 
> Either of the arrays may be larger than the other. In my actual problem both the arrays are huge, so I was wondering if there was a smart efficient way to do it.
> 
> Thanks in advance.

doc setdiff
0
Reply Andy 8/30/2010 5:27:36 PM


Great, thanks!
"Andy " <myfakeemailaddress@gmail.com> wrote in message <i5gpm8$1e8$1@fred.mathworks.com>...
> "jay jay" <jay.oberoi@yahoo.com> wrote in message <i5gov7$d8s$1@fred.mathworks.com>...
> > Hi,
> > 
> > I have two arrays:
> > 
> > date_array1 = [ 20101201; 20091201; 20091101; 20100101 ];
> > 
> > date_array2 = [ 20081201; 20101201; 20091201; 20061201; 20100101 ];
> > 
> > I basically want to compare the two arrays and get only the elements of second array date_array2 that are not present in date_array1.
> > 
> > So in the above example I want to get a result of:
> > 20081201
> > 20061201
> > 
> > Either of the arrays may be larger than the other. In my actual problem both the arrays are huge, so I was wondering if there was a smart efficient way to do it.
> > 
> > Thanks in advance.
> 
> doc setdiff
0
Reply jay 8/30/2010 5:43:05 PM

2 Replies
434 Views

(page loaded in 0.007 seconds)

Similiar Articles:













7/23/2012 7:31:05 PM


Reply: