How to merge arrays in julia

Hello,
I have two arrays like this:

ulia> soln1
retcode: Success
Interpolation: Automatic order switching interpolation
t: 5-element Array{Float64,1}:
 0.0
 0.23056783545255075
 1.117776876821525
 2.470121871347117
 2.5
u: 5-element Array{Array{Float64,1},1}:
 [1000.0, 0.0, 0.0]
 [1122.192002548497, 0.0, 0.0]
 [1748.727601815643, 0.0, 0.0]
 [3438.588077255191, 0.0, 0.0]
 [3490.342988172429, 0.0, 0.0]

julia> soln2
retcode: Success
Interpolation: Automatic order switching interpolation
t: 57-element Array{Float64,1}:
  2.5
...
  6.345783848634277
  â‹®
  7.954813105553676
...
 20.0
u: 57-element Array{Array{Float64,1},1}:
 [3490.342988172429, 0.0, 1.0e8]
...
 [3208.560197325081, 0.0007928568460220974, 0.8821627287560089]
 â‹®
 [7173.092759205297, 1.095531236362228e-6, 0.0007379875987002946]
...

julia> 

How can I merge them properly?
Thank you

You don’t seem to only have two arrays, but two more complicated objects that seem to be a solution to some problem. What do you mean when you describe these as “array”?

Also, when asking questions, it is generally a good idea to give a concrete example of what you want. That avoids the difficulty in describing the operation in natural language. For example, if you have the two arrays [1,2,3] and [4,5,6], what does “merging” them mean? What is the final result you want?

3 Likes

You are right, this is the solution of a differential equation. I gather that it is an array because Julia tells that it is a 5-element Array{Float64,1} and 5-element Array{Array{Float64,1},1}. I understand there is a first element that is a vector (t) and a second element (u) that is a vector of vectors (each element is an array of three values).
I simply wanted to concatenate the t vectors of the two arrays together, and the u arrays together…

vcat?

2 Likes

I see you have an object (whose Type can be checked with typeof(soln1)).

To check its members, in the REPL you can type

julia> soln1.

and then tab twice to check its fields.

As an example, let’s say that soln1.t returns array t. Then to combine your arrays into a third, you just do:

julia> vcat(soln1.t, soln2.t)