gnuplot中的karplus方程 [英] karplus equation in gnuplot

查看:158
本文介绍了gnuplot中的karplus方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想绘制karplus方程


I want plot karplus equation

f(t)=a*cos(t+o)**2 + b*cos(t+o) + c 

带有gnuplot的

用于不同的a,b,c,o值.特别是参数a,b,c,o具有表格形式(在文件data.dat中):

with gnuplot for different value of a, b, c, o values. In particular the parameters a, b, c, o have tabular form (in file data.dat):

a b c o
1 2 3 60
4 5 6 180
-3 -5 -9 -120

并且t的范围是

-180 to 180

data.dat文件中的每一行.

for each row in data.dat file.

你能帮我吗?谢谢大家.

Can you help me? Thanks everyone.

Lucio

推荐答案

AFAIK无法在函数中绘制带有不同参数的参数文件",因为plot命令可以任一个使用函数来绘制数据文件:

AFAIK it is not possible to have a "parameter file" with different parameters to plot in a function since the plot command can either take a function to plot or a datafile:

plot {<ranges>}
     {<iteration>}
     {<function> | {"<datafile>" {datafile-modifiers}}}
     {axes <axes>} {<title-spec>} {with <style>}
     {, {definitions{,}} <function> ...}

因此您必须创建一个数据文件,其中列出了t和功能值以供gnuplot绘制.另一个解决方法,如果您只需要绘制有限数量的karplus函数,则可能会很有用:

So either you have to create a datafile where your t and functional values are listed for gnuplot to plot. An other workaround, that might be useful if you only have a limited number of karplus functions to plot is this:

set angles degrees
set xrange [-180:180]

f(x, a, b, c, o) = a*cos(x+o)**2 + b*cos(x+o) + c
title(n) = sprintf("f_%d", n)

plot a = 1 b = 2 c = 3 o = 60 f(x, a, b, c, o) t title(1), \
     a = 4 b = 5 c = 6 o = 180 f(x, a, b, c, o) t title(2), \
     a = -3 b = -5 c = -9 o = -120 f(x, a, b, c, o) t title(3)

现在,您直接指定参数并相应地绘制函​​数.

Now you specify the parameters directly and and plot the function accordingly.

或者,您也可以像这样实现迭代:

Alternatively you could implement an iteration like so:

plot for [a = 1:10:2] b = 2 c = 3 o = 60 f(x, a, b, c, o) t title(a)

不幸的是,不可能将迭代嵌套在gnuplot中,因此您只需要改变一个参数即可.

Unfortunately it is not possible to nest iterations in gnuplot, so you have to cope with just having one parameter to vary.

这篇关于gnuplot中的karplus方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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