MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Creating Matrix from vectors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100703] Re: [mg100691] Creating Matrix from vectors
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Thu, 11 Jun 2009 21:40:09 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200906111108.HAA21218@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

Mathematica does not have "matrix" as a built-on primitive type of data 
structure.  To Mathematica a matrix is just a list of lists, with the 
individual lists being its rows.  For example,

   v1 = {1, 2, 3}; v2 = {4, 5, 6};
   m = {v1, v2}
{{1,2,3},{4,5,6}}

And if you want to display such a list of lists to look like a 
conventional matrix, wrap it in MatrixForm:

   MatrixForm[m]

If you want to interchange "rows" with "columns", you may use Transpose:

   Transpose[m]
{{1,4},{2,5},{3,6}}

And now if you wrap that with MatrixForm, you'll see the sort of display 
you want, where the original "vectors" v1 and v2 appear as the columns.

Kinu wrote:
> Suppose i have a n number of vectors say s1, s2,... sn. I want to
> create a matrix such that these n vectors are the n columns of the matrix.
> I tried using A = {s1,s2,..,sn};
> however this keep the vectors intact and stacks them one below the
> other. How can i make a matrix from these??
> Can anyone please help me with this.
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: AnimationDirection when Exporting
  • Next by Date: Re: problem writing debugging utility function
  • Previous by thread: Re: Creating Matrix from vectors
  • Next by thread: Re: Creating Matrix from vectors