Re: How to construct a vector whose elements are also vectors?
- To: mathgroup at smc.vnet.net
- Subject: [mg82871] Re: [mg82813] How to construct a vector whose elements are also vectors?
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Thu, 1 Nov 2007 05:27:05 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200710311120.GAA22728@smc.vnet.net>
- Reply-to: murray at math.umass.edu
stat = Partition[Table[0, {20}], 2] {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}} stat[[1]] = {29, -17}; stat {{29,-17},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}} stat[[{3,5}]]={{"Hello","world!"},{x,y}}; stat {{29,-17},{0,0},{Hello,world!},{0,0},{x,y},{0,0},{0,0},{0,0},{0,0},{0,0}} (It's worth your while to read and try the Mathematica documentation about List some more. Don't use iteration if you don't need to.) Guofeng Zhang wrote: > Hi, there, > I'd like to construct a vector whose elements are also vectors. I used > the following conmands: > > Table[stat[i], {i, 1, 10}]; > For[i = 1, i <= 10, (stat[i] = Array[0 &, {10, 2}]); i++]; > > Then I try > stat[1] > which yields > {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, > {0, 0}} > > This seems okay. However, I don't know how to endow values to it, for > instance change the first {0, 0} to {1,0}. > > Thank you for your time and help! > Henry > > -- 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