Hi,
my aim is to add a new row to a 2D array in a for-loop.
If I execute
A = Array{Int64}(undef, 0, 2)
A = [A; [1 2]]
A = [A; [2 3]]
println(A)
I receive [1 2; 2 3] that is correct. But if I run it in a for loop:
C = Array{Int64}(undef, 0, 2)
for i = 1:5
global C = [C; [i, i+1]]
end
println(C)
I get
ERROR: LoadError: ArgumentError: number of columns of each array must match (got (2, 1))
Stacktrace:
[1] _typed_vcat(::Type{Int64}, ::Tuple{Array{Int64,2},Array{Int64,1}}) at .\abstractarray.jl:1439
[2] typed_vcat at .\abstractarray.jl:1453 [inlined]
[3] vcat(::Array{Int64,2}, ::Array{Int64,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\SparseArrays\src\sparsevector.jl:1077
[4] top-level scope at C:\Users\M\Desktop\tsssspp.jl:11
[5] include(::String) at .\client.jl:457
[6] top-level scope at REPL[48]:1
in expression starting at C:\Users\M\Desktop\tsssspp.jl:10
I do not understand the problem.