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

sgougeon at free.fr sgougeon at free.fr
Wed Jun 13 15:07:24 CEST 2018


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



More information about the users mailing list