If it’s not longer than that, you can easily do that with hcat:

julia> ySol = [rand(2) for _ in 1:20]
20-element Array{Array{Float64,1},1}:
 [0.6383963589240325,0.952443724507759]  
 [0.8543445393734637,0.5497614848396764] 
 [0.7180883594522589,0.2699980988282249] 
 [0.879654133666188,0.008079464648794499]
 [0.32422181761199975,0.2699464303552557]
 [0.26787882268244223,0.4271951131306577]
 [0.2613014121460324,0.9629053122741955] 
 [0.3473409046077083,0.8228842149724882] 
 [0.9074984806753585,0.5398222579191083] 
 [0.850898493473214,0.10093766734240517] 
 [0.7103469388877257,0.6295378284694306] 
 [0.7598286632595868,0.9313542937160446] 
 [0.7174343129435241,0.9971075729799896] 
 [0.49861954369803874,0.3683763032284182]
 [0.8145463614876596,0.616519930503598]  
 [0.6922945697041882,0.646282075186712]  
 [0.8108510573789565,0.20586283678616368]
 [0.46599068004928035,0.7351678286521091]
 [0.6932932362204158,0.8608833557510405] 
 [0.1747785273075091,0.9016114746811359] 

julia> hcat(ySol...)'
20x2 Array{Float64,2}:
 0.638396  0.952444  
 0.854345  0.549761  
 0.718088  0.269998  
 0.879654  0.00807946
 0.324222  0.269946  
 0.267879  0.427195  
 0.261301  0.962905  
 0.347341  0.822884  
 0.907498  0.539822  
 0.850898  0.100938  
 0.710347  0.629538  
 0.759829  0.931354  
 0.717434  0.997108  
 0.49862   0.368376  
 0.814546  0.61652   
 0.692295  0.646282  
 0.810851  0.205863  
 0.465991  0.735168  
 0.693293  0.860883  
 0.174779  0.901611

Note, however, that splatting like this isn’t very performant (yet…) so if 
you need to do this in a tight loop, or for a much longer array ySol, you 
should consider other options.

// T

On Thursday, February 18, 2016 at 7:23:55 PM UTC+1, Chris Nabold wrote:


>
> I have a collection ySol:
> julia> ySol=collect(ySol)
> 21-element Array{Any,1}:
>  1x2 Array{Float64,2}:
>  9000.0  0.0
>  1x2 Array{Float64,2}:
>  8998.79  -4.80427
>  1x2 Array{Float64,2}:
>  8995.29  -9.0677
>  1x2 Array{Float64,2}:
>  8989.86  -12.4678
>  1x2 Array{Float64,2}:
>  8982.97  -14.9547
>  1x2 Array{Float64,2}:
>  8975.04  -16.66
>  1x2 Array{Float64,2}:
>  8966.41  -17.7772
>  1x2 Array{Float64,2}:
>  8957.33  -18.4864
>  1x2 Array{Float64,2}:
>  8947.97  -18.9266
>  1x2 Array{Float64,2}:
>  8938.43  -19.195
>  1x2 Array{Float64,2}:
>  8928.79  -19.3559
>  1x2 Array{Float64,2}:
>  8919.09  -19.4502
>  1x2 Array{Float64,2}:
>  8909.35  -19.5037
>  1x2 Array{Float64,2}:
>  8899.59  -19.5323
>  1x2 Array{Float64,2}:
>  8889.82  -19.5457
>  1x2 Array{Float64,2}:
>  8880.04  -19.5498
>  1x2 Array{Float64,2}:
>  8870.27  -19.5484
>  1x2 Array{Float64,2}:
>  8860.5  -19.5435
>  1x2 Array{Float64,2}:
>  8850.73  -19.5366
>  1x2 Array{Float64,2}:
>  8840.96  -19.5285
>  1x2 Array{Float64,2}:
>  8831.2  -19.5196
> How can I convert it into an array of dimension 20,2
> eg yy=zeros(20,2)
> yy=ySol
> Thank you for your help
>
​

Reply via email to