|
From: Jon <dev...@gm...> - 2011-01-31 09:00:52
|
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 |
|
From: Thomas S. <t.s...@fz...> - 2011-01-31 09:33:08
|
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. |
|
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 > |
|
From: Thomas S. <t.s...@fz...> - 2011-02-09 10:38:45
|
use 'columnstring(0)' note: numbering of read in data lines starts with 0 (have a look at 'pseudocolumns' in the manual) bsmile wrote: > > 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 >> > ------------------------------------------------------------------------------ > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: > Pinpoint memory and threading errors before they happen. > Find and fix more than 250 security defects in the development cycle. > Locate bottlenecks in serial and parallel code that limit performance. > http://p.sf.net/sfu/intel-dev2devfeb > _______________________________________________ > 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--tp30804801p30881347.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Jon <dev...@gm...> - 2011-02-11 21:58:03
|
Dear Thomas,
I tested the command you suggested, but gnuplot complains that columnstring
command not found, so I changed to stringcolumn command, but it still
complains that
"combined_plot_1.gu", line 8: x range is invalid
but if I change all stringcolumn(0) as stringcolumn(1), then at least it
works. So it seems to me that stringcolumn(0) cannot be corrected executed.
Am I right?
Meanwhile, I think of the following as alternative
p 'aaa.txt' u (cc=sprintf("%i",column(0)), \
vs=vs.'; v'.cc.'='.stringcolumn(1), \
ws=ws.'; w'.cc.'='.stringcolumn(2), \
$1):2 )
but still it is not as elegant as your previous suggestion, so I hope your
advice could work out.
Sincerely,
Jon
On Wed, Feb 9, 2011 at 4:38 AM, Thomas Sefzick <t.s...@fz...>wrote:
>
> use 'columnstring(0)'
> note: numbering of read in data lines starts with 0
> (have a look at 'pseudocolumns' in the manual)
>
>
> bsmile wrote:
> >
> > 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
> >>
> >
> ------------------------------------------------------------------------------
> > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> > Pinpoint memory and threading errors before they happen.
> > Find and fix more than 250 security defects in the development cycle.
> > Locate bottlenecks in serial and parallel code that limit performance.
> > http://p.sf.net/sfu/intel-dev2devfeb
> > _______________________________________________
> > 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--tp30804801p30881347.html
> Sent from the Gnuplot - User mailing list archive at Nabble.com.
>
>
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
|
|
From: Thomas S. <t.s...@fz...> - 2011-02-12 09:52:30
|
sorry, yes, i meant 'stringcolumn(0)'
'stringcolumn(0)' isn't working in gnuplot version 4.4
- here we have to use the sprintf() -,
but in the development version 4.5 it is.
bsmile wrote:
>
> Dear Thomas,
>
> I tested the command you suggested, but gnuplot complains that
> columnstring
> command not found, so I changed to stringcolumn command, but it still
> complains that
>
> "combined_plot_1.gu", line 8: x range is invalid
>
> but if I change all stringcolumn(0) as stringcolumn(1), then at least it
> works. So it seems to me that stringcolumn(0) cannot be corrected
> executed.
> Am I right?
>
> Meanwhile, I think of the following as alternative
>
> p 'aaa.txt' u (cc=sprintf("%i",column(0)), \
> vs=vs.'; v'.cc.'='.stringcolumn(1), \
> ws=ws.'; w'.cc.'='.stringcolumn(2), \
> $1):2 )
>
> but still it is not as elegant as your previous suggestion, so I hope your
> advice could work out.
>
> Sincerely,
> Jon
>
> On Wed, Feb 9, 2011 at 4:38 AM, Thomas Sefzick
> <t.s...@fz...>wrote:
>
>>
>> use 'columnstring(0)'
>> note: numbering of read in data lines starts with 0
>> (have a look at 'pseudocolumns' in the manual)
>>
>>
>> bsmile wrote:
>> >
>> > 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
>> >>
>> >
>> ------------------------------------------------------------------------------
>> > The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio
>> XE:
>> > Pinpoint memory and threading errors before they happen.
>> > Find and fix more than 250 security defects in the development cycle.
>> > Locate bottlenecks in serial and parallel code that limit performance.
>> > http://p.sf.net/sfu/intel-dev2devfeb
>> > _______________________________________________
>> > 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--tp30804801p30881347.html
>> Sent from the Gnuplot - User mailing list archive at Nabble.com.
>>
>>
>>
>> ------------------------------------------------------------------------------
>> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
>> Pinpoint memory and threading errors before they happen.
>> Find and fix more than 250 security defects in the development cycle.
>> Locate bottlenecks in serial and parallel code that limit performance.
>> http://p.sf.net/sfu/intel-dev2devfeb
>> _______________________________________________
>> gnuplot-info mailing list
>> gnu...@li...
>> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> 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--tp30804801p30907931.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|