本文介绍了如何定义和GNUPLOT访问数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是相当简单的问题也许过于简单的问题。但我想找到已经完成这些的方式,甚至在GNUPLOT文件找不到。也许是我的错误或误解的一些关于在GNUPLOT阵列的概念。我的问题是如何定义和GNUPLOT访问数组?

This is rather easy question or maybe too easy question. But i tried to find the way to done these already and could not find even in GNUplot document. Might be my mistake or misunderstood something about array concept in GNUplot. My question is How to define and access array in GNUplot?

请只是提供数组声明简单的例子,在循环分配阵列的价值。我认为这是不够的,我认为这将是其他人太有用了。

Please just provide easy example of array declaration, assign value of array over loop. i think that's enough and i think this will be useful for other people too.

推荐答案

在gnuplot的的splot命令使用关键字阵来定义包含3D绘图函数值N×M的矩阵的大小。

The "splot" command in gnuplot uses the keyword "array" to define the size of NxM matrix that contains function values for a 3D plot.

像什么程序员从C,Pascal中,Python等知道数组不gnuplot的今日(gp5.0)存在。他们可能会实现的一天,因为他们会绘制一个家庭,任意的(如装)参数曲线非常有用的。

Arrays like what a programmer knows from C, Pascal, Python, etc. do not exist in gnuplot today (gp5.0). They might get implemented one day, because they'd be highly useful to plot a family of curves with arbitrary (e.g. fitted) parameters.

如果你感到绝望关于gnuplot的数组,你可以(AB)使用字()函数(和其他字符串函数)实现比较有限的替代品。这也是一个有点麻烦:

If you are desperate about arrays in gnuplot, you can (ab)use the word() function (and other string functions) to achieve a somewhat limited substitute. It's also a bit cumbersome:

array = ""
f(a,x) = a*x
do for [i=1:5] {array = array.sprintf("%.3f",i+rand(0))." " }
print "array = ".array
set xr [0:]; set yr [0:30]
plot for [i=1:5] f(word(array,i),x) title word(array,i)." x"

这例子一组随机数的写入名为数组的字符串变量,事后用它来绘制使用数字​​中的阵为自己坡5线性函数。

This example writes a set of random numbers to a string variable named "array", and afterwards uses it to plot five linear functions that use the numbers in "array" for their slope.

这篇关于如何定义和GNUPLOT访问数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:38