[Scilab-users] unique instruction

classic Classic list List threaded Threaded
2 messages Options
Carrico, Paul-2 Carrico, Paul-2
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] unique instruction

Dear All

In the matrix here after, I want to remove duplicate values in the first column but while keeping the second one as it stands ; I guess Scilab while keep the first occurrence but it’s fine.

I do not remember how to use correctly  “unique” and all my trials failed: can somebody help me?

Thanks

Paul

 

Before :

M = [
0 2
0 6
1 8
2 9
]

After :

M = [
0 2
1 8
2 9
]
 Or 
M = [
0 6
1 8
2 9
]

 

 


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Antoine Monmayrant Antoine Monmayrant
Reply | Threaded
Open this post in threaded view
|

Re: unique instruction

Hello Paul,

You want to keep "unique" values along the first column of M.
Here is how you can get this result:

//////////////////////////////////////////

M = [ 0 2; 0 6; 1 8;2 9]
firstCol=M(:,1);
[dum,ind]=unique(firstCol);
MuniqueFirstCol=M(ind,:);

//////////////////////////////////////////


Hope it helps,


Antoine


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users