【发布时间】:2023-03-10 13:42:01
【问题描述】:
我需要根据在实验室使用万用表收集的数据绘制两个电极之间的等电位线图,我有一组 (x,y) 坐标除以其中测量的电压。
3,07 V 点
2.0 0.0
2.3 2.0
3.1 3.9
2.3 -2.0
3.1 -4.0
3,93 v 点
0.0 0.0
0.1 1.9
0.2 2.9
0.1 -1.0
0.2 -2.0
4,98 V 点
-2.0 0.0
-2.3 2.0
-2.4 2.9
-2.3 -2.0
-2.5 -3.0
我曾尝试将省略号写成参数形式,并使用“fit”命令来拟合椭圆,但结果很糟糕。
set grid
set parametric
set trange [0:2*pi]
fx(t)=a*cos(t)+k
fy(t)=b*sin(t)+h
fit fx(t) '3,07.txt' via a,k
fit fy(t) '3,07.txt' via b,h
plot fx(t),fy(t) notitle ls 7, '3,07.txt' notitle
我认为这与“拟合”算法如何使用最小二乘法有关,因为它接近 y 而不是 x。我说的对吗?
我也尝试用它的一般方程来拟合椭圆。
set grid
f(x, y) = x*x + c1*y*y + d1*x + e1*y + f1
fit f(x, y) '3,07.txt' u 1:2:(0) via ,c1,d1,e1,f1
set contour
set view map
unset surface
set cntrparam levels discrete 0
set isosamples 1000,1000
set table 'contour 1.txt'
splot f(x, y)
set xr [-60:60]
set yr [-60:60]
unset table
unset contour
plot \
'contour 1.txt' lw 2 lc rgb 'red', \
'3,07.txt' w p ps 1.5 lc rgb 'black'
但结果更糟,有人知道我还应该尝试什么吗?
【问题讨论】:
标签: gnuplot ellipse data-fitting