Hi Brian.
On Fri, 28 Nov 2014 08:54:10 -0800 (PST), Brian Cherinka wrote:
>
> So this post is related to my original post here, but it's not quite working out.
> https://groups.google.com/forum/#!topic/comp.lang.idl-pvwave /CtiGTuNqD10
>
> ...
>
> So I have two arrays where I need to extract the elements in one array not in the other, but the elements are not quite exact to one another.
>
> A = [309, 313, 318, 322, 327, 331, 336, 340]
> B = [305, 309, 314, 318, 323, 327, 332, 336, 341, 345]
>
> B is the true array, and A is the "found" array that is missing some elements. I want to find all elements missing from A that exist in B.
>
> The solution I adopted, from the previous post, is something like
>
> diff = 2 ; offset between integers
> temp = value_locate(A,B)
> missloc = where(B-A[temp] gt diff and A[temp+1]-B gt diff, misscount)
>
> This mostly works, however it does not work when the elements that are missing are the edges, i.e. the first or last element.
>
> [...]
The missing elements on the left edge were recognized by the
additional two lines in my draft. But not the missing elements on the
right edge. This is true.
However I would not use the histogram function to overcome this. I
would go a more easy way, which I expect to be both, faster and less
memory consuming. It is only a little change to the code above:
A = [309, 313, 318, 322, 327, 331, 336, 340]
B = [305, 309, 314, 318, 323, 327, 332, 336, 341, 345]
diff = 2 ; offset between integers
temp = value_locate(A,B)
missloc = where((B-A[temp] gt diff and A[temp+1]-B gt diff) or $
a[0]-b gt diff or $ ; elements on the left edge
b-a[n_elements(a)-1] gt diff, $ ; right edge
misscount)
if misscount ge 1 then print,b[missloc]
Good luck again, Heinz
|