> julia> reshape(d,3,2)
3x2 Array{ASCIIString,2}:
"x1" "y2"
"y1" "x3"
"x2" "y3"
This is because of Julia's column-major ordering.
you see the problem ? instead I would like to have :
x1 y1
x2 y2
..
xn yn
In this case, you could use:
julia> reshape(d,2,3)'
3x2 Array{ASCIIStrin
Thank you ! I think I will use this solution :
julia> a = []
0-element Array{Any,1}
julia> b = []
0-element Array{Any,1}
julia> push!(a, 1)
1-element Array{Any,1}:
1
julia> push!(a, 2)
2-element Array{Any,1}:
1
2
julia> a
4-element Array{Any,1}:
1
2
3
4
julia> b
4-element Array{Any,1}:
Thank you very much Matt. In fact I will work with floats, but the idea to
concatenate 2 columns is good !
Le mardi 12 avril 2016 16:58:21 UTC+2, Matt Bauman a écrit :
>
> It'd probably be fastest if you can pre-allocate your array:
>
> A = Array(ASCIIString, 3, 2)
> for i=1:size(A, 1)
> A[i,
On Tue, Apr 12, 2016 at 10:58 AM, Matt Bauman wrote:
> It'd probably be fastest if you can pre-allocate your array:
>
> A = Array(ASCIIString, 3, 2)
> for i=1:size(A, 1)
> A[i, 1] = string('w'+i, 1)
> A[i, 2] = string('w'+i, 2)
> end
>
> If you don't know how many elements you'll have, you
It'd probably be fastest if you can pre-allocate your array:
A = Array(ASCIIString, 3, 2)
for i=1:size(A, 1)
A[i, 1] = string('w'+i, 1)
A[i, 2] = string('w'+i, 2)
end
If you don't know how many elements you'll have, you can use two column
vectors, `c1` and `c2`, and push to them independ
Thank you very much Tim !
In fact I want to create an X,Y array so if I create a 1D array, I can only
append to it (x1,y1) then (x2,y2)... (xn, yn), because I calculate x1
before x2...
julia> d = ["x1", "y1", "x2", "y2", "x3", "y3"]
6-element Array{ASCIIString,1}:
"x1"
"y1"
"x2"
"y2"
"x3"
Note that in `a = Array{Float64,2}`, `a` is a *type*, not an *instance*. You
presumably mean `a = Array(Float64, 0, 0)`.
But Yichao is right that you can't grow a 2d array, only a 1d one.
Best,
--Tim
On Tuesday, April 12, 2016 09:44:16 AM Yichao Yu wrote:
> On Tue, Apr 12, 2016 at 9:38 AM, Fred
Thank you very much Yichao ! This explain all the problems I have... But it
still unclear :
I cannot create an empty 1D array and resize it :
julia> b = Array[]
0-element Array{Array{T,N},1}
julia> b = Array[]
0-element Array{Array{T,N},1}
julia> reshape(b,2,2)
ERROR: DimensionMismatch("new
On Tue, Apr 12, 2016 at 9:38 AM, Fred 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 exactl
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
10 matches
Mail list logo