Reputation: 53
How do I append an element to a 2-D array in Julia? I tried using push!
test = [1 2; 3 4]
push!(test, [8 9])
but I got the following error
ERROR: MethodError: no method matching push!(::Array{Int64,2}, ::Array{Int64,2})
Closest candidates are:
push!(::Any, ::Any, ::Any) at abstractarray.jl:2158
push!(::Any, ::Any, ::Any, ::Any...) at abstractarray.jl:2159
push!(::Array{Any,1}, ::Any) at array.jl:920
...
Stacktrace:
[1] top-level scope at none:0
Thank you!
Upvotes: 2
Views: 106
Reputation: 53
You can do this by concatenating the additional rows.
test = [1 2; 3 4]
vcat(test, [8 9])
Upvotes: 2