我知道如何在示例中使用 $
与 using
plot datafile using f($1):g($2)
我想绘制列数据的函数图。但是我想在循环中使用此功能:
plot for [c=1:10] datafile using f($(c)):g($(c+1))
当然这段代码不能工作。我猜如果我知道如何将整数c
转换为字符串(或单个ASCII字符),那么它就可以工作了。我该怎么做呢?
(如果可以不将整数转换为字符串而完成相同的任务,那也可以。)
我知道如何在示例中使用 $
与 using
plot datafile using f($1):g($2)
我想绘制列数据的函数图。但是我想在循环中使用此功能:
plot for [c=1:10] datafile using f($(c)):g($(c+1))
当然这段代码不能工作。我猜如果我知道如何将整数c
转换为字符串(或单个ASCII字符),那么它就可以工作了。我该怎么做呢?
(如果可以不将整数转换为字符串而完成相同的任务,那也可以。)
gnuplot> a=3; b=6;
gnuplot> plot a*x+b title sprintf("a=%1.2f; b=%1.2f",a,b)
您是否正在寻找类似以下内容的东西:
plot for [c=1:5] datafile using (column(c)):(column(c+1))
绘制数据文件 u 1:2, "" u 2:3, "" u 3:4, "" u 4:5, "" u 5:6
set title sprintf("Polinômio de Taylor no ponto %f ",a)
或者英文版本
set title sprintf("Taylor Polynomial at the point %f ",a)
将数字a转换为前一个字符串来定义标题。 我在循环中使用了这个,在先前计算的泰勒多项式的点a处, 其中包含一个数字的a是while循环的控制变量。
这样行吗?循环语句可能因使用的 shell 不同而不同。下面的示例是使用 bash。
plot '< for i in 1 2 3 4 ; do echo $i ; done' us ($1):($1+1)
gnuplot> a=42
gnuplot> print a." questions"
internal error : STRING operator applied to non-STRING type
gnuplot> print "".a." questions"
42 questions
print
由于类型不匹配而失败。然而第二个工作正常。显然.
是从左到右结合的。