From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

perform action if duplicate array entry found

Hello,

 

I am writing a tuning algorithm to converge on a final value based on the output from my instrument.  In my calculations, I sometimes calculate a value that I derived earlier (due to the sensitivity of the instrument that I am collecting the data from). The "actual data values " array in the example provided, are my actual calculated values.  I would like to perform a function such that if a value appears a second time, I perform a + or - function.  In the attached example, 500 appears 2 times (enteries 0 and 4). How can I perform the + function for the 2nd 500 entry?

 

Thanks,

hiNI.

0 Kudos
Message 1 of 8
(2,964 Views)

What is a "a + or - function"? What is the desired output given the default input of your example?

0 Kudos
Message 2 of 8
(2,954 Views)

Hi,

   There are probably a few different ways to find the duplicates, but my strategy regardless of implementation would be to create a second array of boolean values which mark the duplicates. Then you can just autoindex both arrays in a for loop and do whatever you want with duplicated entries. See the attached screenshot. I justed summed skipping duplicates as an example...

 

Thanks,

-Gabe

0 Kudos
Message 3 of 8
(2,941 Views)

Something like this?

0 Kudos
Message 4 of 8
(2,904 Views)

First of all, you are using LabVIEW 7.1, which is ancient. Most people will not be able to downconvert an example this far back.

 

The way I understand your question is that we need to process the elements one at a time and whenever a value occurs that has been seen before, additional operations need to be performed.

 

In the most simple case, you would need to compare the current value with all previous values, and that will get expensive if the arrays are large. There is probably a better solution using variant attributes.

 

How big are the arrays? how often do duplicates occur? Are the values always integers within a relatively small range? (e.g. 1...a few thousands or millions). Once a duplicate is processed, do the next values also need to be checked against the processed value or only against the original value?

 

We need more detailed information.

0 Kudos
Message 5 of 8
(2,896 Views)

Hello,

 

Here are answers to your questions:

 

1. The arrays can be as big as 10 enteries max.

2. In the 10 enteries, the duplicates may be 4 max.

3. The values are integers and range from x9000 to xDDDD

4. Once the duplicate is processed, the next values DO also need to be checked against the processed value.

 

I was working from my old work station that only has 7.1 installed, however, I can handle up to LabVIEW 13 if you post a solution.

 

Thanks.

hiNi.

0 Kudos
Message 6 of 8
(2,854 Views)

If there are only 10 entries, using "search array" on the exisiting entries is trivial.

If the output of "search array" is <0, the new value is unique. Otherwise it already exists and needs to be processed.

0 Kudos
Message 7 of 8
(2,819 Views)

Even a simple "equal" of the array of existing values with the new value, followed by "or array elements" will tell you if the value already exists. Simply increment/decrement until the new value is unique before accepting it.

0 Kudos
Message 8 of 8
(2,811 Views)