gnuplot:如何将数据文件值保存到一个变量(有条件)? [英] gnuplot : how to save datafile values into a variable (with condition)?

查看:389
本文介绍了gnuplot:如何将数据文件值保存到一个变量(有条件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Gnuplot,我想将一个数据文件的值保存到一个条件变量中。
例如,我有如下的datafile'example.dat':

pre $ column $ column $ $ $ $ $ $
3 4.0
7 6.0

在我的gnuplot脚本中,我想能够在文件'example.dat'($ 1)== 5?$ 2:1中写入:

  variable = / 0

这里就是这样:

  variable = 7.0 

当然值取决于数据文件。



所以有可能?

如果没有,是否可以没有条件? / p>

解决方案

这是我解决问题的方法:
$ b $

  

第2列中的所有条目都将写入A,您可以通过以下方式访问:

 word(A,i)

其中i是原始数(从1开始)
字(A)给出了总长度。

I use Gnuplot and I would like to save values of a datafile into a variable with condition. For example, I have the following datafile 'example.dat':

columnl   column2
   5        7.0
   3        4.0
   7        6.0

In my gnuplot script, I would like to be able to write:

variable = " in the file 'example.dat' ($1)==5 ? $2 : 1/0 "

which would be here the same as:

variable = 7.0

of course the value depends on the datafile.

So is it possible?

If not, is it possible without condition?

解决方案

This is how I worked around the problem:

A=""
plot file u (A=A.sprintf(' %g',$2), $1):2

All the entries from column 2 will be written to A, which you can access then via:

word(A,i)

where i is the number of the raw (starting at 1) words(A) gives you the total length.

这篇关于gnuplot:如何将数据文件值保存到一个变量(有条件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆