如何在gnuplot脚本中实际复制函数

如何在gnuplot脚本中实际复制函数,gnuplot,Gnuplot,下面的例子解释了这一切 f(t)=2*t g(t)=f(t) f(t)=3*t # Now g(t) == 3*t ... but I'd like g(t) to still be 2*t 基本上,我需要它,因为我调用了另一个脚本来设置函数 #usage call scripts arg1 arg2 # set f(t) # "backup" f in f1 f1(t)=f(t) call scripts arg3 arg4 # set f, but also f1 now ... f2

下面的例子解释了这一切

f(t)=2*t
g(t)=f(t)
f(t)=3*t # Now g(t) == 3*t ... but I'd like g(t) to still be 2*t
基本上,我需要它,因为我调用了另一个脚本来设置函数

#usage
call scripts arg1 arg2 # set f(t)

# "backup" f in f1
f1(t)=f(t)

call scripts arg3 arg4 # set f, but also f1 now ...
f2(t)=f(t)

plot f1(t), f2(t) ..

我认为gnuplot无法控制函数分配的这种“后期绑定”

可以使用宏来实现这一点。为此,必须将函数定义定义为字符串:

set macros
ft = "2*t"
g(t) = @ft
ft = "3*t"
f(t) = @ft
plot f(x), g(x)