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> 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> [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. You therefore need permutedims
to get your vector into a row vector.