# Adding a line to the end of an Array

**URL:** <https://discourse.julialang.org/t/adding-a-line-to-the-end-of-an-array/42291>\
**Category:** New to Julia\
**Created:** [June 30, 2020, 9:05am UTC](https://discourse.julialang.org/t/adding-a-line-to-the-end-of-an-array/42291 "2020-06-30T09:05:50Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 30, 2020, 10:42am UTC](https://discourse.julialang.org/t/adding-a-line-to-the-end-of-an-array/42291/9 "2020-06-30T10:42:20Z")

</div>

Just to summarize the answer to your question from the different posts:

You are trying to add a 12 element vector as a row to an 18x12 matrix. You can think of this as vertically concatenating the two. Vectors in Julia are however column vectors by default, and you are looking to append a row vector, so you need to permute the dimensions:

```julia
julia> a = rand(3, 2)
3×2 Array{Float64,2}:
 0.387527 0.230343
 0.682296 0.255378
 0.22481 0.838333

julia> b = rand(2)
2-element Array{Float64,1}:
 0.24946180391946426
 0.24528450122180612

julia> vcat(a, b) # doesn't work as b is 2x1 rather than 1x2
ERROR: ArgumentError: number of columns of each array must match (got (2, 1))
Stacktrace:
 [1] _typed_vcat(::Type{Float64}, ::Tuple{Array{Float64,2},Array{Float64,1}}) at .\abstractarray.jl:1358
 [2] typed_vcat at .\abstractarray.jl:1372 [inlined]
 [3] vcat(::Array{Float64,2}, ::Array{Float64,1}) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\SparseArrays\src\sparsevector.jl:1078
 [4] top-level scope at REPL[114]:1

julia> vcat(a, b')
4×2 Array{Float64,2}:
 0.387527 0.230343
 0.682296 0.255378
 0.22481 0.838333
 0.249462 0.245285

```

`vcat` is the same as doing `[a; b']`, i.e. the array syntax with a semicolon is syntactic sugar for `vcat`:

```julia
julia> [a; b']
4×2 Array{Float64,2}:
 0.387527 0.230343
 0.682296 0.255378
 0.22481 0.838333
 0.249462 0.245285

```

Your other problemn is that your `b` includes non-numerical values, for which `'`, which produces an adjoint, doesn’t work - see the discussion [here](https://discourse.julialang.org/t/transpose-of-an-array-of-strings/40431/3). You therefore need `permutedims` to get your vector into a row vector.

---

_[View the full topic](https://discourse.julialang.org/t/adding-a-line-to-the-end-of-an-array/42291)._
