On Tue, Apr 12, 2016 at 9:38 AM, Fred <[email protected]> wrote: > Hi ! > > The questions I have is so trivial that I spend a long time trying to find > an example on the doc and on the web but I did not manage to do exactly what > I want : > > I want to create an empty 2D array : the function readdlm create exactly > the kind of array I want if I read a CSV file with 2 columns. For example : > > julia> m > 1913x2 Array{Float64,2}: > 201.07 6597.95 > 202.092 17835.7 > 202.944 9667.59 > 204.015 11983.4 > 204.811 7586.52 > 205.803 1.1506 > .... > > > > > I tried to create exactly the same type of array and append values to it : > > julia> a = Array{Float64,2} > Array{Float64,2} > > > push!(a, 10.0,3.0) > ERROR: MethodError: `push!` has no method matching > push!(::Type{Array{Float64,2}}, ::Float64) > Closest candidates are: > push!(::Any, ::Any, ::Any) > push!(::Any, ::Any, ::Any, ::Any...) > push!(::Array{Any,1}, ::ANY) > > > push!(a, [10.0,3.0]) > ERROR: MethodError: `push!` has no method matching > push!(::Type{Array{Float64,2}}, ::Array{Float64,1}) > Closest candidates are: > push!(::Any, ::Any, ::Any) > push!(::Any, ::Any, ::Any, ::Any...) > push!(::Array{Any,1}, ::ANY) > > > append!(a, [10.0,3.0]) > ERROR: MethodError: `append!` has no method matching > append!(::Type{Array{Float64,2}}, ::Array{Float64,1}) > Closest candidates are: > append!{T}(::Array{T,1}, ::AbstractArray{T,1}) > append!{T}(::StatsBase.AbstractHistogram{T,1,E}, ::AbstractArray{T,1}) > append!{T}(::StatsBase.AbstractHistogram{T,1,E}, ::AbstractArray{T,1}, > ::StatsBase.WeightVec{W,Vec<:AbstractArray{T<:Real,1}}) > ... > > > > etc... I tried every possible syntax to append values to an empty 2D array > and I did not find the solution and the correct syntax :)
It's not possible without creating a new one. You can create a 1d one and resize it. > > Thank you for your help ! >
