为了提供一个简单的背景,我正在进行一个控制双稳态螺线管速度的项目,我正在尝试创建该系统的状态空间表示。我的状态空间中的一个变量是F,它是螺线管电枢力。F取决于螺线管的特定几何配置以及铁氧体磁芯和永磁体的BH曲线。F可以描述为电枢轴的位置x和螺线管中的电流i的函数,否则记为F=g(x,i)。
所附的EXCEL表格是从螺线管的Maxwell有限元模型中收集的数据,该模型给出了螺线管上的力(以毫米为单位)和电流(以A为单位)。从我在网上读到的论文(1和2)中,通常的做法是将这条曲线拟合为双三次样条近似。双三次样条线近似可以表示如下所示。
F(T)=g(i,x)=g_0(X)+g_1(X)i+g_2(X)i^2+g_3(X)i^3
其中,当i=1,2,3,4时,g_i(X)=α_i,1+α_i,2x+α_i,3x^2+α_i,4x^3
从这个方程式中,你可以得到16个系数来适应你的数据。我试着用附加的EXCEL数据进行拟合,但它不能拟合0 mm和4.895 mm附近的高度非线性作用力,最终得到高MSE=163.05。
我的数据拟合方法是在MatLab中使用nlinfit()
函数完成的。如果你想复制我的结果,我得到的α系数如下:
[α_11,α_12,α_13,α_14,α_21,α_22,α_23,α_24,α_31,α_32,α_33,α_34,α_41,α_42,α_43,α_44]=[59.6556,-104.012,49.6096,-6.9047,-14.8646,9.3209,-1.8018,-0.0318,-0.2990,0.8670,-0.4706,0.0661,0.0971,-0.0944,0.0197]
这是一张拟合曲线与实际数据的曲线图(红色)。
Force Curve Fit
我认为,问题在于我要拟合的函数,而不是我的拟合方法。但是,我不知道使用什么才是最好的方程式,因为我不认为增加多项式的阶数会有帮助(但也许我错了)。
如果任何人对如何找到一个合适的方程有什么建议,或者对一个你认为适合这个数据的特定方程有什么建议,我将不胜感激!这些数据在输入变量、电流和位置上都是非常对称的,我认为这可能有助于找到合适的方程进行拟合。
谢谢。
**编辑:**忘记附加EXCEL数据。运行代码片段以生成数据表。
<table><tbody><tr><th> </th><th>-7</th><th>-6</th><th>-5</th><th>-4</th><th>-3</th><th>-2</th><th>-1</th><th>0</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th><th>6</th><th>7</th><th>i (A)</th></tr><tr><td>4.895</td><td>30.002332</td><td>21.985427</td><td>6.810482</td><td>-15.670808</td><td>-45.233394</td><td>-77.215051</td><td>-105.258626</td><td>-125.69229</td><td>-137.533424</td><td>-144.608218</td><td>-149.37894</td><td>-153.029304</td><td>-155.689815</td><td>-157.477955</td><td>-158.626949</td><td> </td></tr><tr><td>4.845</td><td>30.232465</td><td>24.087844</td><td>14.620048</td><td>1.72655</td><td>-14.792426</td><td>-35.152992</td><td>-59.469883</td><td>-84.288</td><td>-102.159215</td><td>-114.172775</td><td>-123.557279</td><td>-130.950597</td><td>-136.22158</td><td>-139.785929</td><td>-142.188687</td><td> </td></tr><tr><td>4.795</td><td>30.421325</td><td>24.932531</td><td>17.444529</td><td>7.892998</td><td>-3.856977</td><td>-18.014886</td><td>-34.99118</td><td>-54.76071</td><td>-73.12193</td><td>-87.497601</td><td>-98.824193</td><td>-108.060712</td><td>-114.987903</td><td>-120.253359</td><td>-124.356373</td><td> </td></tr><tr><td>4.745</td><td>30.551303</td><td>25.391767</td><td>18.870906</td><td>10.957517</td><td>1.538053</td><td>-9.535194</td><td>-22.598697</td><td>-38.389555</td><td>-55.208053</td><td>-69.556258</td><td>-81.254268</td><td>-90.739807</td><td>-98.322417</td><td>-104.256711</td><td>-108.853733</td><td> </td></tr><tr><td>4.695</td><td>30.664703</td><td>25.675715</td><td>19.70439</td><td>12.733737</td><td>4.693012</td><td>-4.564309</td><td>-15.382383</td><td>-28.781825</td><td>-44.015781</td><td>-57.405663</td><td>-68.654996</td><td>-78.136226</td><td>-85.96381</td><td>-92.262205</td><td>-97.271558</td><td> </td></tr><tr><td>4.645</td><td>30.727753</td><td>25.865955</td><td>20.238259</td><td>13.853267</td><td>6.664413</td><td>-1.448761</td><td>-10.800537</td><td>-22.615818</td><td>-36.367379</td><td>-48.848877</td><td>-59.549314</td><td>-68.920612</td><td>-76.813046</td><td>-83.32022</td><td>-88.600393</td><td> </td></tr><tr><td>4.395</td><td>30.865921</td><td>26.241471</td><td>21.290271</td><td>16.08672</td><td>10.626372</td><td>4.839985</td><td>-1.602854</td><td>-9.43494</td><td>-18.83834</td><td>-28.636958</td><td>-37.691591</td><td>-45.92364</td><td>-53.263184</td><td>-59.60791</td><td>-64.797286</td><td> </td></tr><tr><td>4.145</td><td>31.095974</td><td>26.462957</td><td>21.68939</td><td>16.805136</td><td>11.820302</td><td>6.696608</td><td>1.18386</td><td>-5.121618</td><td>-12.593724</td><td>-20.872655</td><td>-28.902156</td><td>-36.190138</td><td>-42.81756</td><td>-48.711318</td><td>-53.733812</td><td> </td></tr><tr><td>3.895</td><td>31.46129</td><td>26.783809</td><td>22.050232</td><td>17.24325</td><td>12.414941</td><td>7.549917</td><td>2.463171</td><td>-3.126318</td><td>-9.525282</td><td>-16.772883</td><td>-24.024533</td><td>-30.735935</td><td>-36.907371</td><td>-42.495141</td><td>-47.386621</td><td> </td></tr><tr><td>3.645</td><td>31.84872</td><td>27.13964</td><td>22.399963</td><td>17.609472</td><td>12.824883</td><td>8.054302</td><td>3.167199</td><td>-2.022925</td><td>-7.798272</td><td>-14.333423</td><td>-20.98601</td><td>-27.322197</td><td>-33.20454</td><td>-38.422392</td><td>-43.441491</td><td> </td></tr><tr><td>3.395</td><td>32.321379</td><td>27.611153</td><td>22.830246</td><td>18.00384</td><td>13.186564</td><td>8.407782</td><td>3.614684</td><td>-1.377083</td><td>-6.778505</td><td>-12.763999</td><td>-18.950497</td><td>-24.996769</td><td>-30.700952</td><td>-36.002519</td><td>-40.845001</td><td> </td></tr><tr><td>3.145</td><td>32.912865</td><td>28.117376</td><td>23.297908</td><td>18.414747</td><td>13.541529</td><td>8.720016</td><td>3.953985</td><td>-0.893617</td><td>-6.030829</td><td>-11.646948</td><td>-17.480042</td><td>-23.272051</td><td>-28.818368</td><td>-34.05723</td><td>-38.898901</td><td> </td></tr><tr><td>2.895</td><td>33.461235</td><td>28.733026</td><td>23.846096</td><td>18.900341</td><td>13.945926</td><td>9.043626</td><td>4.247023</td><td>-0.554529</td><td>-5.54091</td><td>-10.874341</td><td>-16.437732</td><td>-22.017734</td><td>-27.450488</td><td>-32.671967</td><td>-37.55842</td><td> </td></tr><tr><td>2.645</td><td>34.20239</td><td>29.399207</td><td>24.450979</td><td>19.429789</td><td>14.378361</td><td>9.384043</td><td>4.50818</td><td>-0.228657</td><td>-5.110888</td><td>-10.256221</td><td>-15.598685</td><td>-20.988768</td><td>-26.283234</td><td>-31.452038</td><td>-36.351057</td><td> </td></tr><tr><td>2.395</td><td>34.914372</td><td>30.186026</td><td>25.182228</td><td>20.081931</td><td>14.90649</td><td>9.757508</td><td>4.793411</td><td>-0.022121</td><td>-4.818618</td><td>-9.801554</td><td>-14.977042</td><td>-20.209359</td><td>-25.40338</td><td>-30.537892</td><td>-35.491473</td><td> </td></tr><tr><td>2.145</td><td>35.805782</td><td>31.056782</td><td>26.042754</td><td>20.849744</td><td>15.526359</td><td>10.206612</td><td>5.079032</td><td>0.217373</td><td>-4.533031</td><td>-9.394064</td><td>-14.424973</td><td>-19.520352</td><td>-24.601559</td><td>-29.643549</td><td>-34.578382</td><td> </td></tr><tr><td>1.895</td><td>36.912236</td><td>32.230447</td><td>27.190092</td><td>21.88521</td><td>16.388134</td><td>10.852426</td><td>5.512241</td><td>0.53729</td><td>-4.252576</td><td>-9.060047</td><td>-13.988674</td><td>-18.990227</td><td>-23.997652</td><td>-28.971069</td><td>-33.911535</td><td> </td></tr><tr><td>1.645</td><td>38.220177</td><td>33.55963</td><td>28.522922</td><td>23.132328</td><td>17.438377</td><td>11.652987</td><td>6.043032</td><td>0.901</td><td>-3.941164</td><td>-8.721107</td><td>-13.565417</td><td>-18.470008</td><td>-23.400995</td><td>-28.283206</td><td>-33.172001</td><td> </td></tr><tr><td>1.395</td><td>40.089435</td><td>35.460059</td><td>30.362062</td><td>24.861205</td><td>18.933028</td><td>12.805265</td><td>6.809413</td><td>1.39481</td><td>-3.583199</td><td>-8.390298</td><td>-13.200262</td><td>-18.057954</td><td>-22.938035</td><td>-27.768679</td><td>-32.61952</td><td> </td></tr><tr><td>1.145</td><td>42.604155</td><td>38.034489</td><td>32.852205</td><td>27.179704</td><td>21.024509</td><td>14.456797</td><td>7.936568</td><td>2.129503</td><td>-3.092501</td><td>-7.988163</td><td>-12.808929</td><td>-17.635859</td><td>-22.475901</td><td>-27.255258</td><td>-32.039299</td><td> </td></tr><tr><td>0.895</td><td>46.740509</td><td>42.104713</td><td>36.736597</td><td>30.755343</td><td>24.224614</td><td>17.087908</td><td>9.853802</td><td>3.360219</td><td>-2.293161</td><td>-7.426018</td><td>-12.358482</td><td>-17.254878</td><td>-22.122863</td><td>-26.910174</td><td>-31.65453</td><td> </td></tr><tr><td>0.645</td><td>53.63405</td><td>48.823341</td><td>43.145538</td><td>36.706073</td><td>29.56244</td><td>21.689267</td><td>13.405102</td><td>5.735263</td><td>-0.786028</td><td>-6.417941</td><td>-11.659605</td><td>-16.769755</td><td>-21.760135</td><td>-26.617262</td><td>-31.321544</td><td> </td></tr><tr><td>0.395</td><td>66.719783</td><td>61.669457</td><td>55.479065</td><td>48.279934</td><td>40.173712</td><td>31.232975</td><td>21.372923</td><td>11.406692</td><td>2.961089</td><td>-3.87916</td><td>-10.044617</td><td>-15.840246</td><td>-21.29497</td><td>-26.408778</td><td>-31.159668</td><td> </td></tr><tr><td>0.25</td><td>81.066195</td><td>75.939181</td><td>69.61686</td><td>62.097845</td><td>53.400235</td><td>43.453173</td><td>31.99206</td><td>19.510149</td><td>8.697597</td><td>0.08383</td><td>-7.513168</td><td>-14.397559</td><td>-20.598789</td><td>-26.139851</td><td>-31.007816</td><td> </td></tr><tr><td>0.2</td><td>88.630566</td><td>83.616297</td><td>77.408061</td><td>69.893348</td><td>60.994658</td><td>50.53292</td><td>38.266849</td><td>24.550308</td><td>12.460448</td><td>2.685077</td><td>-5.844277</td><td>-13.434216</td><td>-20.125472</td><td>-25.947463</td><td>-30.897252</td><td> </td></tr><tr><td>0.15</td><td>98.70275</td><td>93.957875</td><td>87.989331</td><td>80.562783</td><td>71.487536</td><td>60.477972</td><td>47.235774</td><td>32.081579</td><td>18.171011</td><td>6.62184</td><td>-3.316554</td><td>-11.987794</td><td>-19.434567</td><td>-25.69812</td><td>-30.791197</td><td> </td></tr><tr><td>0.1</td><td>112.445855</td><td>108.177395</td><td>102.579509</td><td>95.384179</td><td>86.396863</td><td>75.206226</td><td>61.200302</td><td>44.511365</td><td>27.603038</td><td>13.116663</td><td>0.853254</td><td>-9.609617</td><td>-18.315011</td><td>-25.317822</td><td>-30.657122</td><td> </td></tr><tr><td>0.05</td><td>129.953349</td><td>126.729465</td><td>122.16493</td><td>115.888176</td><td>107.735583</td><td>97.599944</td><td>84.78044</td><td>67.007035</td><td>45.133323</td><td>25.293443</td><td>8.703572</td><td>-5.123796</td><td>-16.206876</td><td>-24.614329</td><td>-30.421939</td><td> </td></tr><tr><td>0</td><td>146.979281</td><td>145.477655</td><td>143.182354</td><td>139.720174</td><td>134.892754</td><td>128.593272</td><td>119.228637</td><td>104.230568</td><td>81.016758</td><td>53.376624</td><td>27.161422</td><td>5.354242</td><td>-11.477492</td><td>-23.316319</td><td>-30.26605</td><td> </td></tr><tr><td>x (mm)</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr></tbody></table>
1条答案
按热度按时间xjreopfe1#
我已经对提供的数据应用了
griddata
和fit
。poly23
不是适合所提供数据的曲面的最佳选择,让我解释一下:**1.-**这是提供的数据
全部清除;全部关闭;CLC
我已经删除了左侧的第一列,它似乎与您提供的屏幕截图不匹配。
这是由
surf
提供的数据直接使用
surf
不添加点,着色的表面正在渲染,可以使用hs1
句柄查看surf
生成的点数,以此为surf
输出29x15我们付出什么,就得到什么。
**2.-**在MatLab中,将曲面拟合到3D数据的默认命令是
griddata
适用于此处
现在,此
surf
中的控制柄hs2
包含将曲面拟合到29X15(435)点时生成的所有附加点。检查
**4.-**根据所使用的MatLab版本,还可以使用命令
fit
来将曲面拟合到3D点。4.1.-
fit
选项poly11
使用简单的线性多项式曲线f1_poly11(x,y) = p00 + p10*x + p01*y
正如预期的那样,线性近似并不是最适合所提供的点。
**4.2.-**线性插值法做得很好
**4.3.-**选项
cubicinterp
是分段三次插值法**4.4.-**选项
lowess
是局部线性回归又一次,这种回归没有预期的那么好,是吗?
**4.5.-**和
poly23
是您使用以下表达式对nlinfit
使用的类似近似值:MatLab返回一个可信区间,始终赞赏具有95%置信限的系数。
**5.-**所以
griddata
非常擅长拟合曲线。我想提一下这一点,因为
已经包含了逼近曲面的所有点,真的需要多项式吗?
它可能更容易和更快地生成曲面,然后无论您的编码是关于什么,只需读取和处理存储的点的数据。
补充评论
这里有由John D‘Errico提供的名为
gridfit
的griddata
的改进版本https://uk.mathworks.com/matlabcentral/fileexchange/8998-surface-fitting-using-gridfit?s_tid=srchtitle_surface%20fitting_2
如果您觉得这个答案有用,请您考虑点击接受的答案。
谢谢