如何在gnuplot中插入离散值,如n = 1,2,3,4,5 ....

时间:2013-02-20 19:18:14

标签: plot gnuplot

你好我需要在gnuplot中绘制一个函数:

h(x) = ((sin(x/2))**2)/((sin(n*x/2))**2)

我不知道的是如何设置

n = ...-2,-1,0,1,2... 

或者也许

n = 1,2,3,4...

Soo我该怎么做?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:3)

gnuplot中的函数定义可以采用多个参数:

h(x,n) = ((sin(x/2))**2)/((sin(n*x/2))**2)

如果要绘制此类函数的范围,可以使用for结构:

plot for [i=-2:2] h(x,i)

do for

do for [i=-2:2] {
    plot h(x,i)
    print i # or do other stuff
}