|
From: Arun P. <ape...@lb...> - 2011-04-01 01:33:04
|
Hi
not sure if this is a bug or not...
the following works:
gnuplot> set macros
gnuplot> A="a=1"
gnuplot> a=1.0
gnuplot> A=sprintf("a=%f",2)
gnuplot> @A
gnuplot> print a
2.0
but this doesn't:
gnuplot> set macros
gnuplot> A="a=1.111";a=1;A=sprintf("a=%f",2); @A;print a
warning: A is not a string variable
1
I also ran into something similar, here is a short version of it:
set macros
A="2.0"
f(t) = (\
A= sprintf("a=2.0"),\
@A,\
"some text")
print f(1)
that didn't set a to 2.0...
An here a longer: What I wanted to do is having a function that saves
results from a fit to some variables, so that I can reuse them later
after doing more fits... I thought I could use:
CP_FIT(A,A_err,mu,mu_err,sig,sig_err,offset,offset_err,file,type) = ( \
MA = sprintf("%s_%s_A = %f",file,type,A),\
MAe = sprintf("%s_%s_A_err = %f",file,type,A_err),\
Mmu = sprintf("%s_%s_mu = %f",file,type,mu),\
Mmue = sprintf("%s_%s_mu_err = %f",file,type,mu_err),\
Msig = sprintf("%s_%s_sig = %f",file,type,sig),\
Msige = sprintf("%s_%s_sig_err = %f",file,type,sig_err),\
Moff = sprintf("%s_%s_off = %f",file,type,offset),\
Moffe = sprintf("%s_%s_off_err = %f",file,type,offset_err),\
@MA, @Mmu, @Msig, @MAe, @Mmue, @Msige,@Moff,@Moffe,\
sprintf("copying variables for %s %s",file,type))
but the macros never got called ?! It works though, if I take the line
including all the @M... out and call it by hand after I call CP_FIT.
Tested this with 4.4, 4.5 and the latest CVS (Changelog version 1.3682).
Here is the version output from the CVS build:
gnuplot> show version long
G N U P L O T
Version 4.5 patchlevel 0
last modified March 2011
System: Linux 2.6.38-18-desktop
Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
mailing list: gnu...@li...
faq, bugs, etc: type "help seeking-assistance"
immediate help: type "help"
plot window: hit 'h'
Compile options:
-READLINE +LIBREADLINE +HISTORY
-BACKWARDS_COMPATIBILITY +BINARY_DATA
+GD_PNG +GD_JPEG +GD_TTF +GD_GIF +ANIMATION
-NOCWDRC +X11 +X11_POLYGON +MULTIBYTE +X11_EXTERNAL +USE_MOUSE
+HIDDEN3D_QUADTREE
+DATASTRINGS +HISTOGRAMS +OBJECTS +STRINGVARS +MACROS +IMAGE
+USER_LINETYPES
GNUPLOT_DRIVER_DIR = "/usr/local/libexec/gnuplot/4.5"
GNUPLOT_PS_DIR = "/usr/local/share/gnuplot/4.5/PostScript"
HELPFILE = "/usr/local/share/gnuplot/4.5/gnuplot.gih"
cheers
ARUN
|