Gnuplot:将椭圆拟合到极坐标中的数据集

Gnuplot:将椭圆拟合到极坐标中的数据集,gnuplot,ellipse,polar-coordinates,Gnuplot,Ellipse,Polar Coordinates,对于赋值,我需要绘制一个物体的惯性椭球。 为了做到这一点,我绘制了惯性与角旋转的倒数。完成后,我需要用椭圆拟合绘图 但是我不能在deg模式下绘制数据集,只能在rad模式下绘制,我不知道为什么我的代码不能工作。我还需要帮助绘制椭圆 这是我的密码: set terminal png set output 'tisch.png' set angles radians set polar show polar set parametric set grid polar set size square

对于赋值,我需要绘制一个物体的惯性椭球。 为了做到这一点,我绘制了惯性与角旋转的倒数。完成后,我需要用椭圆拟合绘图

但是我不能在deg模式下绘制数据集,只能在rad模式下绘制,我不知道为什么我的代码不能工作。我还需要帮助绘制椭圆

这是我的密码:

set terminal png
set output 'tisch.png'

set angles radians
set polar
show polar
set parametric
set grid polar
set size square
set trange [0:360]
set rrange [0:0.5]

plot 'A3-daten.txt'  
这是我的数据集:

0       0.494012339
30      0.510681467
60      0.461169413
90      0.42190106
120     0.408044505
150     0.442066272
180     0.496961666

提前感谢您的帮助,并对我的语法错误表示歉意,英语是我的第二/第三语言,尽管我能很好地理解英语,但有时我仍然难以以可理解的方式表达自己。

在极坐标模式下,gnuplot可以拟合并绘制
r(t)
形式的函数,其中,
t
是角度,
r
是距离原点的距离。这意味着我们必须用这种形式来表示一个椭圆

接下来我们咨询。这里我们必须小心:维基百科用于椭圆参数表示的
t
不是gnuplot使用的角度
t
,他们称之为“偏心异常”。改为使用
tw
,参数表示为:

x = a*cos(tw)
y = b*sin(tw)
我们可以将这些方程转换为gnuplot所需的极坐标表示(从笛卡尔坐标到极坐标的已知转换):

我们需要
tw
,所以我们求解第二个方程:

sin(tw) / cos(tw) = (a*sin(t)) / (b*cos(t))
          tan(tw) = (a*sin(t)) / (b*cos(t))
               tw = atan2( a*sin(t), b*cos(t))
可以使用
t-phi
而不是
t
旋转椭圆

现在我们已经完成了数学方程的转换,我们可以从gnuplot开始。剧本是直截了当的:

datafile = "A3-daten.txt"                                  

set terminal pngcairo                                      
set output "ellipse.png"                                   
set size square                                            

tw(t) = atan2(a*cos(t-phi),b*sin(t-phi))                
r(t) = sqrt( (a*cos(tw(t)))**2 + (b*sin(tw(t)))**2 ) 

set polar
set angles degrees                                         

fit r(t) datafile via a,b,phi                              
plot datafile title datafile ls 7, r(t) title "Fit"
我到达:

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = 0.408469         +/- 0.001589     (0.3889%)
b               = 0.51369          +/- 0.001782     (0.3469%)
phi             = 21.0673          +/- 0.7251       (3.442%)

你事先知道椭圆的主轴(与θ=0重合)吗⁰, θ=90⁰) 或者你还必须估计主轴的位置?回答得好,
tw
t
之间的区别非常重要……:)非常感谢!你给我省了很多麻烦和精力!我唯一要做的就是做一个极坐标网格,但我希望我能做到这一点<代码>设置栅格极坐标可能就足够了。有关详细信息,请参见帮助设置网格。
Final set of parameters            Asymptotic Standard Error
=======================            ==========================
a               = 0.408469         +/- 0.001589     (0.3889%)
b               = 0.51369          +/- 0.001782     (0.3469%)
phi             = 21.0673          +/- 0.7251       (3.442%)