gnuplot中的参数函数

时间:2015-02-04 20:57:07

标签: gnuplot

我想知道如何操纵参数化1-D函数。例如,我想绘制参数a的不同值的高斯: F(X)= EXP(-a *(X-1)** 2)

我知道我可以为a的许多值创建不同的函数f(x),但我想知道是否有一种方法可以为a = 1,2,3等绘制此函数。

感谢。

2 个答案:

答案 0 :(得分:3)

是的,只需定义您的函数,使其将变量参数作为输入:

f(x,a)=exp(-a*(x-1)**2)

然后循环它。它可以按顺序完成(“1至1间隔为1”):

plot for [a=1:3:1] f(x,a) t "a = ".a

或使用值列表:

plot for [a in "1 2 3"] f(x,a) t "a = ".a

enter image description here

答案 1 :(得分:1)

使用以下命令

gnuplot> f(x) = a*x
gnuplot> plot for [a = 1:3:1] f(x) title sprintf("a=%d",a)

我得到以下情节

enter image description here

您可能希望通过以下命令阅读可以获得的说明

gnuplot> help for
 The `plot`, `splot`, `set` and `unset` commands may optionally contain an
 iteration for clause.  This has the effect of [...]

gnuplot> help sprintf
 `sprintf("format",var1,var2,...)` applies standard C-language format specifiers
 to multiple arguments and returns the resulting string. If you want to
 use gnuplot's own format specifiers, you must instead call `gprintf()`.
 For information on sprintf format specifiers, please see standard C-language
 documentation or the unix sprintf man page.

HTH

相关问题