LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check if every group 15 elements of a 1D array are not the same

I don't understand why min=max would work because only two elements are being compared. All elements need to be the same to be considered true so each has to be compared somehow regardless. Extracting one such as the first element and using it to compare to the others is my suggestion. 

0 Kudos
Message 11 of 15
(712 Views)

If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right? No other element can be larger than the max or smaller that the min.

 

(You might run into trouble if the array is DBL and might even contain e.g. NaN, but equal comparison should never be done on DBL anyway. Too dangerous. No such issues with strings, integers, for example. On a side note, it is completely unclear why "array min&max" does not accept booleans! Please vote for this idea!!!! Thank.)

0 Kudos
Message 12 of 15
(708 Views)

@altenbach wrote:

If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right?


Not always.  Array Max & Min ignores NaNs.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 13 of 15
(687 Views)

@paul_cardinale wrote:

@altenbach wrote:

If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right?


Not always.  Array Max & Min ignores NaNs.


(Yes, that's what I wrote in italic above)

 

One way around it would be to add each group of 15 to a new set. If the set has size=1 at the end, all elements are the same. Works even if all 15 elements are NaN. 😄 (Not sure how useful that would be, but still.... )

 

None of this code should be used for Floating point numerics anyway, even if there are no NaNs.

0 Kudos
Message 14 of 15
(668 Views)

@altenbach wrote:

@paul_cardinale wrote:

@altenbach wrote:

If you have a huge array and find the largest and smallest value AND if these two are the same, we can deduce that ALL values are the same. Right?


Not always.  Array Max & Min ignores NaNs.


(Yes, that's what I wrote in italic above)

 

One way around it would be to add each group of 15 to a new set. If the set has size=1 at the end, all elements are the same. Works even if all 15 elements are NaN. 😄 (Not sure how useful that would be, but still.... )

 

None of this code should be used for Floating point numerics anyway, even if there are no NaNs.


Sometimes it might be handy to have fuzzy comparisons.  Of course the tricky part would be defining the fuzz.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 15 of 15
(647 Views)