I have an Array d
that contains an Array of floats:
julia> d 99-element Array{Array{Float64,1},1}: ...
I'm trying to convert it into a 2-dimensional Array, and I sucessfully achieved my goal with:
data = Array(Float64,length(d),length(d[1])) for i in 1:length(d) for j in 1:length(d[1]) data[i,j] = d[i][j] end end
Is there a simpler way of doing this?
An Array in Julia can be created with the use of a pre-defined keyword Array() or by simply writing array elements within square brackets([]). There are different ways of creating different types of arrays.
Reshaping array dimensions in Julia | Array reshape() Method The reshape() is an inbuilt function in julia which is used to return an array with the same data as the specified array, but with different specified dimension sizes. Parameters: A: Specified array.
Julia provides a very simple notation to create matrices. A matrix can be created using the following notation: A = [1 2 3; 4 5 6]. Spaces separate entries in a row and semicolons separate rows. We can also get the size of a matrix using size(A).
hcat(d...)
and vcat(d...)
should do what you want.
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