用Mathematica 利用非线性最小二乘法 实现曲线拟合 代码如下data = {{0,0},{0.000115,0.09},{0.000173,0.13},{0.000231,0.17},{0.000346,0.23},{0.000461,0.25},{0.0005,0.24}};model = D^2/(D^2 + (0.7 D + 2416.4)^2)*(Sin[0.5*x*Sqrt[D*D + (0.
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 19:41:56
用Mathematica 利用非线性最小二乘法 实现曲线拟合 代码如下data = {{0,0},{0.000115,0.09},{0.000173,0.13},{0.000231,0.17},{0.000346,0.23},{0.000461,0.25},{0.0005,0.24}};model = D^2/(D^2 + (0.7 D + 2416.4)^2)*(Sin[0.5*x*Sqrt[D*D + (0.
用Mathematica 利用非线性最小二乘法 实现曲线拟合
代码如下
data = {{0,0},{0.000115,0.09},{0.000173,0.13},{0.000231,0.17},{0.000346,0.23},{0.000461,0.25},{0.0005,0.24}};
model = D^2/(D^2 + (0.7 D + 2416.4)^2)*(Sin[0.5*x*Sqrt[D*D + (0.84 D + 2899.7)^2]])^2;
fit = FindFit[data,{model,{D >= 0}},{D},x]
modelf = Function[{x},Evaluate[model /.fit]]
Plot[modelf[x],{x,0,0.0005},Epilog -> Map[Point,data]]
数据 {{0,0},{0.000115,0.09},{0.000173,0.13},{0.000231,0.17},{0.000346,0.23},{0.000461,0.25},{0.0005,0.24}}
以方程D^2/(D^2 + (0.7 D + 2416.4)^2)*(Sin[0.5*x*Sqrt[D*D + (0.84 D + 2899.7)^2]])^2 为model 求出D的值并得出曲线拟合的图
但是用上面的代码计算出的D的值 有点问题(应该是几千的数值 但是结果才是1.03) 而且曲线拟合的图也不对
用Mathematica 利用非线性最小二乘法 实现曲线拟合 代码如下data = {{0,0},{0.000115,0.09},{0.000173,0.13},{0.000231,0.17},{0.000346,0.23},{0.000461,0.25},{0.0005,0.24}};model = D^2/(D^2 + (0.7 D + 2416.4)^2)*(Sin[0.5*x*Sqrt[D*D + (0.
上次偷懒了,没继续往下看,不好意思^^
把后两行改成:
modelf = Function[{x},Evaluate[model /.fit]][x]
Plot[modelf,{x,0,0.5},Epilog -> Map[Point,data]]
注意也只是把[x]换了个位置,还是笔误,
运行可得
1.82153*10^-7 Sin[1450.28 x]^2
图我昨天上传了一天都没通过,真没想通这也不和谐了?今天从略好了...
Q2算是解决.
从图上看你的函数频率是很高的,这是由拟合函数的形式决定的,至少都是2899.7.
用十来个离散点(而且相对频率来说分得很散了)来拟合高频率的曲线意义已经不大,我试着把第三句的{D >= 0}改成{D >= 1000},{D >= 2000},{D >= 5000},得到的结果为:
{D -> 1005.43},{D -> 2000.},{D -> 5002.49},可见D基本已经失效.
我不太清楚你的实验背景和数据来源,感觉还是要从拟合函数那里找找问题了.