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 called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to eliminate duplicate elements from a vector?

Cornel
19-Tanzanite

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?

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

Cornel
19-Tanzanite
(To:LucMeekes)

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

Cornel
19-Tanzanite
(To:Cornel)

@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

Cornel
19-Tanzanite
(To:LucMeekes)

Ah, ok

 

Cornel_0-1695225397442.png

Werner_E
25-Diamond I
(To:Cornel)

Werner_E_0-1695251565845.png

 

Cornel
19-Tanzanite
(To:Werner_E)

@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
19-Tanzanite
(To:LucMeekes)

Cornel_0-1695369385126.png

ttokoro
20-Turquoise
(To:Cornel)

image.png

image.png

Cornel
19-Tanzanite
(To:ttokoro)

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

Announcements

Top Tags