我使用Gnuplot,我想将数据文件的值保存到带条件的变量中。 例如,我有以下数据文件'example.dat':
columnl column2
5 7.0
3 4.0
7 6.0
在我的gnuplot脚本中,我希望能够写:
variable = " in the file 'example.dat' ($1)==5 ? $2 : 1/0 "
在这里与:
相同variable = 7.0
当然值取决于数据文件。
有可能吗?
如果没有,是否可以无条件?
答案 0 :(得分:0)
这就是我解决问题的方法:
A=""
plot file u (A=A.sprintf(' %g',$2), $1):2
第2列的所有条目都将写入A,您可以通过以下方式访问:
word(A,i)
其中i是原始编号(从1开始) 单词(A)给出总长度。