Biomodèles/Biomodels
SCILAB 3.0 PAS A PAS
SCILAB 3.0 STEP-TO-STEP

Jacques-Deric Rouault

Laboratoire de Neurobiologie de l'Apprentissage, de la Mémoire et de la Communication. CNRS UMR 8620, Bat. 446, Université Paris-Sud, F91400 Orsay

Orscilab
ORSCILAB

19 OPREATIONS GENERALES SUR LES MATRIVES
19 GENERAL OPRATIONS ON MATRICES
19.2 Tris / Sorts
Version 2.1.1 du 28 Février 2005 / Version 2.1.1, February 28th 2005
Biomodèles/Biomodels N°1 pp 0x-0y Décembre 2004 December 2004

Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 20.1 / Next section 20.1

a
Tri (Matrice)
Sort (Matrix)

b
sort (Matrice, Matrix)
c (sort, Matrice, Matrix)
r (sort, Matrice, Matrix)

c
gsort (Matrice, Matrix)
d (gsort,
Matrice, Matrix)
g (gsort,
Matrice, Matrix)
i (gsort,
Matrice, Matrix)
d
r (gsort, Matrice, Matrix)
lr (gsort, Matrice, Matrix)
e
c (gsort, Matrice, Matrix)
lc (gsort, Matrice, Matrix)

Scilab propose deux tris : décroissant par sort ou croissant/décroissant par gsort.
Scilab proposes two sorts : in decreasing order with sort, in increasing or decreasing order with gsort.

La fonction sort trie les valeurs d'une matrice flottante, complexe ou de chaines de caractères par ordre décroissant.
The function sort sorts the values of a float, complex or string matrix in decreasing order.


// PROGRAMME SPAS190201
m1  = [1, 5, 4; 9, 8, 3; 2, 7, 0];
m2 = sort (m1),

Ch19Sc02-Fig01

Il est possible de trier les éléments dans chaque ligne.
It is possible to sort the elements
in each line.

// PROGRAMME SPAS190202
m1  = [1, 5, 4; 9, 8, 3; 2, 7, 0];
m2 = sort (m1, "r"),

Ch19Sc02-Fig02

Il est possible de trier les éléments dans chaque colonne.
It is possible to sort the elements
in each colomn.

// PROGRAMME SPAS190203
m1  = [1, 5, 4; 9, 8, 3; 2, 7, 0];
m2 = sort (m1, "c"),

Ch19Sc02-Fig03

Il est possible d'obtenir l'ordre d'origine des éléments triés.
It is possible to get the original order of the elements
sorted.

// PROGRAMME SPAS190204
m1  = [10, 50, 40; 90, 80, 30; 20, 70, 00];
[m2, k] = sort (m1,"r"),

Ch19Sc02-Fig04

Le tri complexe est effectué en fonction de la taille du module.
The complex sort is performed according to the size of the module.

// PROGRAMME SPAS190205
m1  = [2, 1; 1+%i, %i; 0, 2*%i];
m2 = sort (m1,"c"),

Ch19Sc02-Fig05

Le tri sur les chaines de caractères est effectué suivant l'ordre lexicographique.
The sorton strings is performed according to the lexicographic order.

// PROGRAMME SPAS190206
m1  = ["Abc","abc", "001", "A"; "ABc", "a", "ABC", "abC"];
m2 = sort (m1,"r"),

Ch19Sc02-Fig06

La fonction gsort trie les valeurs d'un vecteur flottant, complexe ou de chaines de caractères par ordre croissant "i" ou décroissant "d". La chaine "g" indique que le tri est effectué sur tous les éléments de la matrice.
The function gsort sorts the values of a float, complex or string vector in increasing "i" or decreasing "d" order. The string "g" indicates that the sort is performed on all the lements of the matrix.

// PROGRAMME SPAS190207
m1  = [1, 5, 4; 9, 8, 3; 2, 7, 0];
m2 = gsort (m1,"g","i"),

Ch19Sc02-Fig07

// PROGRAMME SPAS190208
m1  = [1, 5, 4; 9, 8, 3; 2, 7, 0];
m2 = gsort (m1,"g","d"),

Ch19Sc02-Fig08

Le tri complexe est effectué en fonction de la taille du module.
The complex sort is performed according to the size of the module.

// PROGRAMME SPAS190209
m1  = [2, 1, 1+%i; %i, 0, 2*%i];
m2 = gsort (m1,
"g","i"),

Ch19Sc02-Fig09

Le tri sur les chaines de caractères est effectué suivant l'ordre lexicographique.
The sorton strings is performed according to the lexicographic order.

// PROGRAMME SPAS190210
m1  = ["Abc","abc", "001", "A"; "ABc", "a", "ABC", "abC"];
m2 = gsort (m1,"g","i"),

Ch19Sc02-Fig10

Il est possible d'obtenir l'ordre d'origine (en dimension 1) des éléments triés.
It is possible to get the original order (in dimension 1) of the elements
sorted.

// PROGRAMME SPAS190211
m1  = [10, 50, 40; 90, 80, 30; 20, 70, 0];
[m2,k] = gsort (m1,"g","i"),

Ch19Sc02-Fig11

Il est possible de trier les éléments de la matrice ligne par ligne.
It is possible to sort line per line the elements of the matrix
.

// PROGRAMME SPAS190212
m1  = [10, 50, 40; 90, 80, 30; 20, 70, 0];
m2 = gsort (m1,"r","i"),

Ch19Sc02-Fig12

L'option "lr" permet d'utiliser l'ordre lexical.
The option "lr" uses the lexical order.


// PROGRAMME SPAS190213
m1  = [10, 50, 40; 90, 80, 30; 20, 70, 0];
m2 = gsort (m1,"lr","i"),

Ch19Sc02-Fig13

Il est possible de trier les éléments de la matrice colonne par colonne.
It is possible to sort column per column the elements of the matrix
.

// PROGRAMME SPAS190214
m1  = [10, 50, 40; 90, 80, 30; 20, 70, 0];
m2 = gsort (m1,"c","i"),

Ch19Sc02-Fig14

L'option "lc" permet d'utiliser l'ordre lexical.
The option "lc" uses the lexical order.


// PROGRAMME SPAS190215
m1  = [10, 50, 40; 90, 80, 30; 20, 70, 0];
m2 = gsort (m1,"lc","i"),

Ch19Sc02-Fig15.

Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 20.1 / Next section 20.1