Reputation: 13
That is, merge A whose size is [2,3,4,5] and B whose size is [2,3,6,5], to C whose size is [2,3,10,5].
I know how to do it. But how to complete it efficiently for both me and the machine.
I have tried following code but it did not work.
permutedims([permutedims(A,[1,2,4,3]) permutedims(B,[1,2,4,3])],[1,2,4,3])
Upvotes: 1
Views: 50
Reputation: 10127
You can use the cat
(concatenate) function for this. It takes a keyword argument dims
which allows you to specify the dimension along which you'd like to concatenate.
julia> A = rand(2,3,4,5);
julia> B = rand(2,3,6,5);
julia> C = cat(A, B, dims=3);
julia> size(C)
(2, 3, 10, 5)
You can find out more about the cat
function by typing ?cat
into the Julia REPL.
Upvotes: 2