Depending on the number of samples in your actual problem this might not be 
very performant (because ... is slow for large arrays) but here’s an 
approach using vcat. I had to generate the data slightly differently from 
you, because I had no function flatten.

julia> data = [[t,lowpass(s,sin(t),0.5)...] for t in linspace(0,2pi,20)]
 20-element Array{Any,1}:   [0.0,0.0,0.0]
  # etc...
julia> vcat([d' for d in data]...)
 20x3 Array{Float64,2}:  0.0        0.0           0.0  0.330694   0.16235       
0.324699  # etc...

On Monday, June 16, 2014 8:54:57 AM UTC+2, Andrew Simper wrote:

When I'm working with time series data I often end up with things like this:
>
> function lowpass(lp::Float64, input::Float64, g::Float64)
>     hp::Float64 = input - lp
>     lp += g * hp
>     [lp, hp]
> end
> s = 0.0;
> data=[flatten([t, lowpass(s, sin(t), 0.5)]) for t in linspace(0,2pi,20)]
>
> 20-element Array{Any,1}:
>  [0.0,0.0,0.0]                      
>  [0.330694,0.16235,0.324699]        
>  [0.661388,0.307106,0.614213]       
>  [0.992082,0.418583,0.837166]       
>  [1.32278,0.4847,0.9694]            
>  [1.65347,0.498292,0.996584]        
>  [1.98416,0.457887,0.915773]        
>  [2.31486,0.367862,0.735724]        
>  [2.64555,0.237974,0.475947]        
>  [2.97625,0.0822973,0.164595]       
>  [3.30694,-0.0822973,-0.164595]     
>  [3.63763,-0.237974,-0.475947]      
>  [3.96833,-0.367862,-0.735724]      
>  [4.29902,-0.457887,-0.915773]      
>  [4.62972,-0.498292,-0.996584]      
>  [4.96041,-0.4847,-0.9694]          
>  [5.2911,-0.418583,-0.837166]       
>  [5.6218,-0.307106,-0.614213]       
>  [5.95249,-0.16235,-0.324699]       
>  [6.28319,-1.22465e-16,-2.44929e-16]
>
>
>
> Can anyone please help out with how to turn an array of arrays like this 
> into a 2D array? (or even to pass data as a single chunk into DataFrames to 
> do the job?)
>
>
>
>  
>
> ​

Reply via email to