06-03-2014 12:24 PM
Hello,
i have two boolean arrays.
A[0,1,1,1,0,1,0,0,1,0,0,0,0]
B[0,1,1,1,0,1,0,0,1,0,1,1,0]
They have same size. The only difference are the last two 1,1 in array B.
What do i have to do to get an array that contains only the differences?
C[0,0,0,0,0,0,0,0,0,0,1,1,0]
Thx
06-03-2014 12:31 PM
hi onlyone,
have you tried the Exclusive Or Primitive?
http://zone.ni.com/reference/en-XX/help/371361H-01/glang/exclusive_or/
06-03-2014 12:35 PM
06-03-2014 02:33 PM - edited 06-03-2014 02:39 PM
... And if you want less obscure code, simply use a "not equal" from the comparison palette, same result. 🙂
"Not equal" is much easier to understand for a new programmer than the geeky " xor". It is also more universal and works for arrays of any datatype. For example xor will do bitwise for integers and won't work for DBL, != will always give you a boolean array showing which elements differ.
06-03-2014 02:53 PM
@altenbach wrote:
... And if you want less obscure code, simply use a "not equal" from the comparison palette, same result. 🙂
"Not equal" is much easier to understand for a new programmer than the geeky " xor". It is also more universal and works for arrays of any datatype. For example xor will do bitwise for integers and won't work for DBL, != will always give you a boolean array showing which elements differ.
As long as you compare elements (Default) there is a Right Click Menu option to compare aggrigates that you do not want to use in this case.
06-03-2014 03:04 PM - edited 06-03-2014 03:05 PM
Yes, I was talking exclusively about "compare elements".
XOR does not have an equivalent option to "compare aggregates" anyway, we would need to add an "OR array elements" afterwards.
06-03-2014 03:25 PM
The concern was: "Sometimes newer users just copy and paste primitives from existing code untill they learn to navigate the palettes." Or I would not have mentioned it. Oh! the trouble they can get into that way