如何提高gnuplot中双缝衍射的拟合度?

时间:2019-04-30 23:05:03

标签: gnuplot physics data-fitting

我编写了这段代码,以使双狭缝衍射的强度方程适合我的测量数据。问题在于,拟合图与测量数据的图不成比例。 测量的数据是一个如下所示的txt文件:

0 0 10224 
1 1.00048851978505 10460
...
1050 1050.5129457743 59573
...
2047 2048 10518

我尝试了尽可能多的变量来赋予拟合函数选项以使其与图对齐并为变量提供良好的起始值,但是拟合似乎仍然在合适的数据点附近,尽管看起来似乎是正确的形状。函数winkel(x)用于将测量的x值(第二垂直列)从像素转换为弧度,导致对弧度强度Int(x)(https://de.wikipedia.org/wiki/Doppelspaltexperiment)进行计算,然后测量宽度2048像素宽的摄像头传感器的干涉图案的显示。

set title "Intensity"
set xlabel "pixels"
set ylabel "tics"
#d slit distance
#a slit width
#b proportional constant
#c,g moves the center of the fit function
#lambda wave length of the light
#Int(x) intensity function
#k maximum distraction angle thats still on the screen and measured
pi = 3.14159
lambda = 632.816e-9
winkel(x) = -k+2*k*(x+g)/2048
beta(x) = (pi*d/lambda)*sin(winkel(x))
alpha(x) = (pi*a/lambda)*sin(winkel(x))
f(x)=b*(cos(beta(x))**2) * ((sin(alpha(x))/alpha(x))**2)+c
a=0.0006
d=0.0002
b=60000
c=10000
g=50
k=0.002
fit f(x) "...\\2ohnefilter.txt" using 2:3 via a,b,c,d,g,k
plot "...\\2ohnefilter.txt" using 2:3 , f(x)

拟合函数应与测量数据的图一样高和宽,我该如何实现? 预先感谢。

1 个答案:

答案 0 :(得分:0)

诀窍是用手缩小变量的起始值,直到不再需要拟合为止。不管怎么说,还是要谢谢你。 如果有人好奇k是最重要的相关变量。

对不起,如果我应该删除问题而不是自己回答,那么请删除此问题。