arrays - 在 Julia 中按列堆叠数组

标签 arrays stack julia

我正在尝试将两个一维数组堆叠在一列中。

a = [] #1D array
b = [] #1D array
c = reshape(a, b, 1)           # I am expecting it to put array 'b' under array 'a'

我可以知道这是在 Julia 中堆叠数组的正确语法和方法吗?

最佳答案

这是你想要的吗?

julia> a = [1, 2]
2-element Array{Int64,1}:
 1
 2

julia> b = [3, 4]
2-element Array{Int64,1}:
 3
 4

julia> vcat(a, b)
4-element Array{Int64,1}:
 1
 2
 3
 4

julia> [a; b] # the same as vcat but with a shorter syntax
4-element Array{Int64,1}:
 1
 2
 3
 4

另请参阅https://docs.julialang.org/en/v1/manual/arrays/#man-array-concatenation .

关于arrays - 在 Julia 中按列堆叠数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65494879/

相关文章:

javascript - 在以下情况下如何从每个数组元素中删除\'?

jquery - 如何创建 JSON 数组?

java - 将元素添加到 Stack 对象的 HashTable

struct - 为什么 NamedTuples 和(不可变的)结构是分开的?

arrays - 使用 D 中任意数量的元素初始化数组

java - 在 Java 中防止 NullPointerException

c++ - 编译器如何使用编译器生成的临时文件确定函数所需的堆栈大小?

c++ - 为将来的 QThreadPool 线程和/或 pthread_create 调用设置默认堆栈大小

set - Julia 集在哪些方面是不可变的?

plot - 如何在 Julia 中绘制 .txt 中的值