Can we form a julia matrix whose elements are vectors? I have tried the following but it only formed a matrix of Int.
julia> [[1, 2] [2, 3]; [4, 5] [3, 5]]
4×2 Matrix{Int64}:
1 2
2 3
4 3
5 5
But I wanted [1, 2] to be the first element not 1. Is it possible?
Here is one way to do it:
julia> [[[1, 2]] [[2, 3]]; [[4, 5]] [[3, 5]]]
2×2 Matrix{Vector{Int64}}:
[1, 2] [2, 3]
[4, 5] [3, 5]
another would be:
julia> reshape([[1, 2], [4, 5], [2, 3], [3, 5]], 2, 2)
2×2 Matrix{Vector{Int64}}:
[1, 2] [2, 3]
[4, 5] [3, 5]
but maybe there is some better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With