Intermediate Julia
Anthony Markham
Quantitative Developer
# Create a 1-D array (vector)
my_1d_array = [1, 2, 3, 4, 5, 6]
6-element Vector{Int64}:
1
2
3
4
5
6
;
to denote a new row.# Define a matrix
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
# Return '2' - first row, second column
println(my_matrix[1, 2])
2
:
operator allows us to select all values in a row or column.2×3 Matrix{Int64}:
1 2 3
4 5 6
# Return the entire third column
println(my_matrix[:, 3])
[3, 6]
getindex()
is another way to access elements within an array.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
Intermediate Julia