[Scilab-users] Remove duplicate rows and sustain original order of rows

Izabela Wójcik-Grząba iwoj at il.pw.edu.pl
Wed Jun 13 15:30:45 CEST 2018


Thanks a lot all of you. The first method is fine provided that you 
change the last command for: N=M(k,:). I think it is the same as Samuel 
wrote in a shorter form.

Iza



W dniu 13.06.2018 15:07, sgougeon at free.fr napisał(a):
> Hello,
> 
> ----- Mail original -----
> De: "CHEZE David 227480"
> À: "Users mailing list for Scilab" <users at lists.scilab.org>
> 
>> Hi Iza,
>> 
>> Just consider this tip from the unique help page:
>> 
>> Extracted components, rows or columns can be resorted in their initial 
>> order by sorting k:
>> [N, k] = unique(M);      k = gsort(k,"g",i); N = N(k)
>> [N, k] = unique(M, "c"); k = gsort(k,"g",i); N = N(:, k)
>> [N, k] = unique(M, "r"); k = gsort(k,"g",i); N = N(k, :)
> 
> I recently added this tip (in 6.0.1 doc), but it is wrong.
> This mistake is already fixed for SCilab 6.0.2 @
> https://codereview.scilab.org/#/c/19944/3/scilab/modules/elementary_functions/help/en_US/setoperations/unique.xml
> 
> Example:
> M = int8([2  0  2  2  1  1  1  2  1  1  0  1  1  0  1  1
>           0  1  2  0  1  2  2  0  1  1  2  0  1  0  0  0
>           ])
> [uc, kc] = unique(M, "c")
> 
> // Get unduplicated columns in initial order:
> M(:, gsort(kc,"g","i"))
> 
> Samuel
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users



More information about the users mailing list