小编Mas*_*lie的帖子

如何转换Array {Array {Int64,2},1}到Array {Int64,2}

在Julia中,我想将定义为2D数组的Vector的数据转换为Matrix的2D数组.如下例所示,我想将数据转换为数据t,但到目前为止我还没有成功.我该如何处理此案?

julia> s = [[1 2 3], [4 5 6], [7 8 9]]
3-element Array{Array{Int64,2},1}:
 [1 2 3]
 [4 5 6]
 [7 8 9]

julia> t = [[1 2 3]; [4 5 6]; [7 8 9]]
3××3 Array{Int64,2}:
 1  2  3
 4  5  6
 7  8  9

julia> s |> typeof
Array{Array{Int64,2},1}

julia> t |> typeof
Array{Int64,2}

julia> convert(Array{Int64, 2}, s)
ERROR: MethodError: Cannot `convert` an object of type Array{Array{Int64,2},1} to an object of type Array{Int64,2}
This may have arisen …
Run Code Online (Sandbox Code Playgroud)

arrays matrix julia

3
推荐指数
1
解决办法
369
查看次数

标签 统计

arrays ×1

julia ×1

matrix ×1