曲线拟合估计参数-平方反比定律 [英] curve fitting estimate parameter - inverse square law

查看:129
本文介绍了曲线拟合估计参数-平方反比定律的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制一个绘图力与位置的关系图(根据库仑定律),并估计常数e0. 我有charges的值,q1 = 1,q2 = 1. 例如,我有

I want to make a plot force vs position (for coulomb's law) and estimate the constant e0. I have the values of charges , q1=1,q2=1. I have for example the

position=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1];

force=[0.08,0.015,0.013,0.0062,0.0016,0.00519,-0.00159,0.00118,...
    0.0061,0.00155,0.00143];

库仑为F =(1/4 * pi * e0)* q1 * q2/r ^ 2. 因此,它的形式为:

Coulomb is F= (1/4*pi*e0) * q1*q2/r^2. So, it is in the form:

y = ax ^ -m,其中a =(q1 * q2/4 * pi * e0)

y=ax^-m , where a= (q1*q2/4*pi*e0)

我正在做

p=polyfit(-log10(position),log10(force),1);  % I am not sure about  '1' and minus

m=p(1);
a=10^(p(2)); % I am not sure about a 



xp=0.1:0.1:1.1;
yp=a*xp.^(-m);


plot(position,force,'o',xp,yp)

e0=q1*q2/4*pi*a

我找不到e0的正确值,我做错了吗? m值应为-2,但我正在使用:

I am not finding a right value for e0.Am I doing something wrong? The m value should be -2 but I am taking :

m =

m =

1.6287-0.2008i

1.6287 - 0.2008i

推荐答案

有两个错误的原因.首先,您错过了库仑定律定义中的一些括号.应该是

There are a couple of reasons this is wrong. Firstly, you've missed some parentheses out of your definition of Coulomb's law. It should be

F = 1/(4*pi*e0) * q1 * q2 * r^-2

这意味着您对e0的最终计算应该像

This means that your final calculation of e0 should go like

a = 10^p(2);
e0 = ((q1 * q2) / (4 * pi)) / a;

另一个错误的原因是,实际上,法律的定义对于您的上下文仍然是错误的.那里只有正电荷(q1q2),但显然在某些时候力变为负电荷.由于您正在日志空间中估计参数,因此将无法使用此功能,因为您会得到一个复数.您对数据的库仑定律的定义应为

The other reason this is wrong is that, in fact, the definition of the law is still wrong for your context. You have only positive charges (q1, q2) there, but clearly the force goes negative at some point. Since you're working in log-space to estimate the parameters, this is not going to work as you will get a complex number out. Your definition of Coulomb's law for your data should be

|F| = 1/(4*pi*e0) * |q1 * q2| * r^-2

也就是说,您只有绝对值.因此,您应该使用abs(force)而不是仅仅使用force进行拟合.

That is, you only have the absolute values. Therefore you should do the fitting using abs(force) instead of just force.

这篇关于曲线拟合估计参数-平方反比定律的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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