LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array and for loops

hi all!
I have to perform a calculation inside a for loop and store the
results in an array of integer. My problem is: the n-th result has to
be compared with all the elements already stored in the array during
the previous (n-1)-th interations and then added to array only if it
is not equal to any element in it.
how can i do that?

Thanks
Yattaman
0 Kudos
Message 1 of 2
(2,502 Views)
> I have to perform a calculation inside a for loop and store the
> results in an array of integer. My problem is: the n-th result has to
> be compared with all the elements already stored in the array during
> the previous (n-1)-th interations and then added to array only if it
> is not equal to any element in it.
> how can i do that?
>

There are two general approaches. The straightforward approach is simply
to loop comparing with the element. You can easily turn this into a
subVI if you like.

If your array gets very large, this will become inefficient and you
might consider keeping the array sorted and using Search 1D array. If
the order is important, keep two arrays, one in the original order, and
the other sorted. Note that the benefit of this wi
ll also depend on how
often you get duplicates.

Greg McKaskle
0 Kudos
Message 2 of 2
(2,502 Views)