使用“为...绘制".在gnuplot中改变参数 [英] Using "plot for" in gnuplot to vary parameters

查看:85
本文介绍了使用“为...绘制".在gnuplot中改变参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用gnuplot中的plot for功能来绘制具有变化参数的函数.这是一个例子

I want to use the plot for feature in gnuplot to plot functions with varying parameters. Here an example

par = "1 2" #two values for the parameter
f(x,a) = sin(a*x)
g(x,a) = cos(a*x)
plot for [i=1:words(par)]  g(x, word(par,i)), f(x, word(par,i))

我期望的是对四个函数g(x,1)g(x,2f(x,1)f(x,2)的绘制.

What I expect is the plotting of the four functions g(x,1), g(x,2, f(x,1), and f(x,2).

但是出于任何原因,只绘制了三个函数,即:g(x,1)g(x,2f(x,2).

But for whatever reason only three functions are plotted, namely: g(x,1), g(x,2, and f(x,2).

这对我来说完全是武断的.

This seems completely arbitrary to me.

有人可以帮我吗?

推荐答案

您必须重复for条件:

plot for [i=1:words(par)]  g(x, word(par,i)), for [i=1:words(par)] f(x, word(par,i))

这篇关于使用“为...绘制".在gnuplot中改变参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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