在朱莉娅的列中组合和堆叠数组
Combine and stack arrays in columns in julia
我正在尝试组合两个一维数组并将它们堆叠成列,
a = [1 2 3]
b = [4 5 6]
# such that, they produce
a b
c = [1 4
2 5
3 6]
# the python syntax for such operation is
np.stack_column((a,b))
有人可以为这个操作推荐 julia 语法吗?
我的一位朋友建议了两种执行方法,
1. transpose(vcat(a,b))
hcat(a', b')
2. reshape(hcat(a,b), (3,2))
两者都将创建
的输出
Array{Int64,2}:
1 4
2 5
3 6
3×2 数组{Int64,2}:
1 4
2 5
3 6
我正在尝试组合两个一维数组并将它们堆叠成列,
a = [1 2 3]
b = [4 5 6]
# such that, they produce
a b
c = [1 4
2 5
3 6]
# the python syntax for such operation is
np.stack_column((a,b))
有人可以为这个操作推荐 julia 语法吗?
我的一位朋友建议了两种执行方法,
1. transpose(vcat(a,b))
hcat(a', b')
2. reshape(hcat(a,b), (3,2))
两者都将创建
的输出 Array{Int64,2}:
1 4
2 5
3 6
3×2 数组{Int64,2}: 1 4 2 5 3 6