Julia intermédiaire
Anthony Markham
Quantitative Developer
# Créer un tableau 1D (vecteur)
my_1d_array = [1, 2, 3, 4, 5, 6]
6-element Vector{Int64}:
1
2
3
4
5
6
; pour indiquer une nouvelle ligne.# Définir une matrice
my_matrix = [1 2 3; 4 5 6]
2×3 Matrix{Int64}:
1 2 3
4 5 6
2×3 Matrix{Int64}:
1 2 3
4 5 6
# Retourne « 2 » : première ligne, deuxième colonne
println(my_matrix[1, 2])
2
: permet de sélectionner toutes les valeurs d'une ligne ou d'une colonne.2×3 Matrix{Int64}:
1 2 3
4 5 6
# Retourner toute la troisième colonne
println(my_matrix[:, 3])
[3, 6]
getindex() est une autre façon d'accéder aux éléments d'un tableau.2×3 Matrix{Int64}:
1 2 3
4 5 6
println(getindex(stock, 1, 2))
2
array_1 = [1 2 3; 4 5 6]
array_2 = [7 8 9; 10 11 12]
concat_array = [array_1; array_2]
4×3 Matrix{Int64}:
1 2 3
4 5 6
7 8 9
10 11 12
Julia intermédiaire