LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find from 1D array and build new one

Solved!
Go to solution

hey...im quite new in LV..

 

My "big"Smiley Sad problem is:

 

I have 1D array of numbers :

 

  • 10
  • 10
  • 20
  • 20
  • 20
  • 10
  • 10
  • 30
  • 45
  • 10
  • 10

 

and i wanna build and collect numbers in new 1D array

Like this:

 

  • 10
  • 20
  • 30
  • 45

Tnx so much 🙂

 

 

 

0 Kudos
Message 1 of 13
(2,766 Views)

So essentially, you want to remove redundant elements?

 

Norbert

 

EDIT: What data type are your elements? If they are integer, it is rather simple.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 13
(2,765 Views)

Yes i wanna remove redundant elements.

My data type is "double".

 

tnx

0 Kudos
Message 3 of 13
(2,761 Views)

The simplest solution is often the best. You need to sort the array first then check if the current value is same as previous, if so, don't add.

 

Find and Build.png

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 4 of 13
(2,743 Views)

@bsvare wrote:

The simplest solution is often the best. You need to sort the array first then check if the current value is same as previous, if so, don't add.

 

Find and Build.png


That solution is good unless they want to keep the original order.  To keep the original order, you need to use the Search 1D Array to see if the current element has a duplicate.  If it does, delete the duplicate.  Perform the search again until no duplicates are found.  Then do the same operation with the next element.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 13
(2,740 Views)

@crossrulz wrote:

@bsvare wrote:

The simplest solution is often the best. You need to sort the array first then check if the current value is same as previous, if so, don't add.

 

Find and Build.png


That solution is good unless they want to keep the original order.  To keep the original order, you need to use the Search 1D Array to see if the current element has a duplicate.  If it does, delete the duplicate.  Perform the search again until no duplicates are found.  Then do the same operation with the next element.


So, you suggest more of this:

Find and Build2.png

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 6 of 13
(2,736 Views)

I suggest to be aware of issues with comparing floating point numbers with "equal" or "not equal"!

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 13
(2,732 Views)
Solution
Accepted by topic author ant_inter

"The simplest solution is often the best"

 

Smiley Very Happy

 


Message 8 of 13
(2,723 Views)

@Don_Phillips wrote:

"The simplest solution is often the best"

 

Smiley Very Happy

 



I think Don has us beat.  Oh the things you can find if you take the time to dig around...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 13
(2,709 Views)

hey...super...it works...tnx to all 🙂

 

tnx again 🙂

0 Kudos
Message 10 of 13
(2,674 Views)