Julia Array Concatenation dimension mismatch -



Julia Array Concatenation dimension mismatch -

i have dimensional mismatch problem when using y =[x,a] concatenate 2 arrays:

x = reshape(1:16, 4, 4) x = mean((x ./ mean(x,1)),2)' = zeros(3) println(x) y =[x,a] print (y)

if seek combining them error:

mismatch in dimension 2

both variables x , appear in same dimensions in console:

println(x) [0.7307313376278893 0.9102437792092966 1.0897562207907034 1.2692686623721108] println(a) [0.0,0.0,0.0]

but x in sec dimension. there way combine arrays can in dimension 1?

y = [0.7307313376278893 0.9102437792092966 1.0897562207907034 1.2692686623721108, 0.0,0.0,0.0]

the problem transposing x (putting ' @ end of line) end following:

julia> size(x) (1,4) julia> size(a) (3,)

so when seek y=[x,a] julia rightfully complains cannot concatenate them.

there (at least) 2 solutions:

1) don't transpose x:

x = reshape(1:16, 4, 4) x = mean((x ./ mean(x,1)),2) = zeros(3) println(x) y =[x,a] print (y)

2) transpose a , concatenate without comma:

x = reshape(1:16, 4, 4) x = mean((x ./ mean(x,1)),2)' = zeros(3)' println(x) y =[x a] print (y)

in first case have size(y) = (7, 1) , in sec case have size(y) = (1,7), alternative take depend on want size of y.

arrays multidimensional-array julia-lang

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -