Julia: Converting an Array of Arrays into a Two-Dimensional Array

I have an Array d that contains a floating point array:

 julia> d 99-element Array{Array{Float64,1},1}: ... 

I am trying to convert it to a two-dimensional array, and I have successfully achieved my goal:

 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 an easier way to do this?

+6
source share
1 answer

hcat(d...) and vcat(d...) should do what you want.

+10
source

Source: https://habr.com/ru/post/971634/


All Articles