[julia-users] How to append two arrays?

2014-09-09 Thread Diego Tapias
Consider the arrays given by

v = [1.,2.,3.]

w = [2.,4.,6.]

As you know both are arrays of dimension 1. I want to form the matrix with
its columns given by v and w. How can I do that (I tried with “cat” but it
didn’t worh)? How can it be generalized for n arrrays.

Thanks in advance
​


Re: [julia-users] How to append two arrays?

2014-09-09 Thread Stefan Karpinski
append!(v,w) – it modifies and returns v.


On Wed, Sep 10, 2014 at 12:25 AM, Diego Tapias dandrove...@gmail.com
wrote:

 Consider the arrays given by

 v = [1.,2.,3.]

 w = [2.,4.,6.]

 As you know both are arrays of dimension 1. I want to form the matrix with
 its columns given by v and w. How can I do that (I tried with “cat” but it
 didn’t worh)? How can it be generalized for n arrrays.

 Thanks in advance
 ​



Re: [julia-users] How to append two arrays?

2014-09-09 Thread John Myles White
Try vcat/hcat.

 -- John

On Sep 9, 2014, at 3:31 PM, Diego Tapias dandrove...@gmail.com wrote:

 Thanks for answering!, but what if I want to form a matrix of dimension 2 and 
 not an array of dimension 1.
 
 2014-09-09 17:27 GMT-05:00 Stefan Karpinski ste...@karpinski.org:
 append!(v,w) – it modifies and returns v.
 
 
 On Wed, Sep 10, 2014 at 12:25 AM, Diego Tapias dandrove...@gmail.com wrote:
 Consider the arrays given by
 
 v = [1.,2.,3.]
 
 w = [2.,4.,6.]
 
 As you know both are arrays of dimension 1. I want to form the matrix with 
 its columns given by v and w. How can I do that (I tried with “cat” but it 
 didn’t worh)? How can it be generalized for n arrrays.
 
 Thanks in advance
 
 ​
 
 



Re: [julia-users] How to append two arrays?

2014-09-09 Thread Keno Fischer
If I understand correctly, you want hcat:

julia hcat(v,w)
3x2 Array{Float64,2}:
 1.0  2.0
 2.0  4.0
 3.0  6.0

The general version of that is `cat`.

On Tue, Sep 9, 2014 at 6:31 PM, Diego Tapias dandrove...@gmail.com wrote:
 Thanks for answering!, but what if I want to form a matrix of dimension 2
 and not an array of dimension 1.

 2014-09-09 17:27 GMT-05:00 Stefan Karpinski ste...@karpinski.org:

 append!(v,w) – it modifies and returns v.


 On Wed, Sep 10, 2014 at 12:25 AM, Diego Tapias dandrove...@gmail.com
 wrote:

 Consider the arrays given by

 v = [1.,2.,3.]

 w = [2.,4.,6.]

 As you know both are arrays of dimension 1. I want to form the matrix
 with its columns given by v and w. How can I do that (I tried with “cat” but
 it didn’t worh)? How can it be generalized for n arrrays.

 Thanks in advance





Re: [julia-users] How to append two arrays?

2014-09-09 Thread Diego Tapias
yay! That's what I wanted.
Thank you guys

2014-09-09 17:33 GMT-05:00 Keno Fischer kfisc...@college.harvard.edu:

 If I understand correctly, you want hcat:

 julia hcat(v,w)
 3x2 Array{Float64,2}:
  1.0  2.0
  2.0  4.0
  3.0  6.0

 The general version of that is `cat`.

 On Tue, Sep 9, 2014 at 6:31 PM, Diego Tapias dandrove...@gmail.com
 wrote:
  Thanks for answering!, but what if I want to form a matrix of dimension 2
  and not an array of dimension 1.
 
  2014-09-09 17:27 GMT-05:00 Stefan Karpinski ste...@karpinski.org:
 
  append!(v,w) – it modifies and returns v.
 
 
  On Wed, Sep 10, 2014 at 12:25 AM, Diego Tapias dandrove...@gmail.com
  wrote:
 
  Consider the arrays given by
 
  v = [1.,2.,3.]
 
  w = [2.,4.,6.]
 
  As you know both are arrays of dimension 1. I want to form the matrix
  with its columns given by v and w. How can I do that (I tried with
 “cat” but
  it didn’t worh)? How can it be generalized for n arrrays.
 
  Thanks in advance