|
From: Jon <dev...@gm...> - 2011-02-08 21:03:22
|
Thanks, Thomas, very enlightening! Basically you created a string which contains the characters forming the commands to create all the variables, then run the string as a macro. A bit further question, what if the data file does not have the first column, say bbb.txt 0.56 0.45 0.56 0.65 and I still want to read these variables into an array v1 = 0.56 v2 = 0.45 v3 = 0.56 v4 = 0.65 if still follow your logic, I don't have a columnstring(?) to give 1,2,3,4 ..., then what should I do? Thanks again, Sincerely, Jon On Mon, Jan 31, 2011 at 3:33 AM, Thomas Sefzick <t.s...@fz...>wrote: > > try this: > > set macro > set term dumb > vs="" > ws="" > plot 'aaa.txt' using ( \ > vs=vs.'; v'.stringcolumn(1).'='.stringcolumn(1), \ > ws=ws.'; w'.stringcolumn(1).'='.stringcolumn(2), \ > $1):2 > print "vs: |".vs."|" > print "ws: |".ws."|" > @vs > @ws > show var > > > bsmile wrote: > > > > Dear All, > > > > I just asked something about mathematical operation, and Thomas gave me > > very > > useful hint. So let me ask something more advanced in my point of view. > Is > > it possible to define an array in gnuplot, and read each row of a file > > into > > the array, for example, > > > > 1 0.56 > > 2 0.45 > > 3 0.56 > > 4 0.65 > > > > ? > > > >>From what I know, I would think of the following > > > > p 'aaa.txt' u ( 'v'.$1=$1, 'w'.$1=$1 ):2 > > > > and it seems that > > > > v1=1, w1=0.56 > > v2=2, w2=0.45 > > ... > > > > But if I run the code, it fails, complaining that ')' expected > > > > Any suggestions? > > > > Thanks, > > > > Sincerely, > > Jon > > > ------------------------------------------------------------------------------ > > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > > Finally, a world-class log management solution at an even better > > price-free! > > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > > February 28th, so secure your free ArcSight Logger TODAY! > > http://p.sf.net/sfu/arcsight-sfd2d > > _______________________________________________ > > gnuplot-info mailing list > > gnu...@li... > > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > > > > > -- > View this message in context: > http://old.nabble.com/read-a-datafile-into-an-array%2C-is-it-possible--tp30804801p30804971.html > Sent from the Gnuplot - User mailing list archive at Nabble.com. > > > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better > price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |