cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How to eliminate duplicate elements from a vector?

Cornel
18-Opal

How to eliminate duplicate elements from a vector?

Hello,

I have this vector:

 

Cornel_2-1695219548958.png

 

I want automatically to eliminate duplicate elements, and to retain only those elements which are not duplicate from the vector:

Cornel_3-1695219713745.png

How to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:Cornel)

Here's one method:

LucMeekes_0-1695221182051.png

example:

LucMeekes_1-1695221194148.png

Success!
Luc

View solution in original post

11 REPLIES 11
LucMeekes
23-Emerald III
(To:Cornel)

Here's one method:

LucMeekes_0-1695221182051.png

example:

LucMeekes_1-1695221194148.png

Success!
Luc

Thank you.
If there are other solutions and other ideas (from anyone) they are welcome as well.

@LucMeekes 

 

Cornel_0-1695223035844.png

 

 

Cornel_0-1695223468106.png

Why in the second case function does not work properly? Why I need to give separately entire vector, and not t variable? In the first case it worked...

LucMeekes
23-Emerald III
(To:Cornel)

Probably the cause is numerical (in)accuracy. Your numbers have 17 significant digits at most. The set() function requires exact equality.

Success!
Luc

Ah, ok

 

Cornel_0-1695225397442.png

Werner_E
24-Ruby V
(To:Cornel)

Werner_E_0-1695251565845.png

 

@LucMeekes 

 

Cornel_0-1695281888346.png

 

OK

Cornel_1-1695281904294.png

Cornel_2-1695281912058.png

 

Not OK

Cornel_3-1695281926610.png

Cornel_4-1695281942931.png

 

Is it possible to modify the above set() function in order to accept also a matrix?

 

LucMeekes
23-Emerald III
(To:Cornel)

Do you want them by column:

LucMeekes_0-1695317628905.png

LucMeekes_1-1695317636212.png

or over the entire matrix:

LucMeekes_2-1695317657078.png

LucMeekes_3-1695317666436.png

Which can also be:

LucMeekes_4-1695317933059.png

 

Success!
Luc

Cornel_0-1695369385126.png

ttokoro
20-Turquoise
(To:Cornel)

image.png

image.png

@LucMeekes @Werner_E  @ttokoro 
Ok. Thank you all.

Top Tags