matlab 合适的方程来拟合这种二维非线性数据

1l5u6lss  于 2022-11-15  发布在  Matlab
关注(0)|答案(1)|浏览(179)

为了提供一个简单的背景,我正在进行一个控制双稳态螺线管速度的项目,我正在尝试创建该系统的状态空间表示。我的状态空间中的一个变量是F,它是螺线管电枢力。F取决于螺线管的特定几何配置以及铁氧体磁芯和永磁体的BH曲线。F可以描述为电枢轴的位置x和螺线管中的电流i的函数,否则记为F=g(x,i)
所附的EXCEL表格是从螺线管的Maxwell有限元模型中收集的数据,该模型给出了螺线管上的力(以毫米为单位)和电流(以A为单位)。从我在网上读到的论文(12)中,通常的做法是将这条曲线拟合为双三次样条近似。双三次样条线近似可以表示如下所示。
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,2
x+α_i,3
x^2+α_i,4
x^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>
xjreopfe

xjreopfe1#

我已经对提供的数据应用了griddatafitpoly23不是适合所提供数据的曲面的最佳选择,让我解释一下:

**1.-**这是提供的数据

全部清除;全部关闭;CLC

% supplied data
E=[30.002332    21.985427   6.810482    -15.670808  -45.233394  -77.215051  -105.258626 -125.69229  -137.533424 -144.608218 -149.37894  -153.029304 -155.689815 -157.477955 -158.626949 
30.232465   24.087844   14.620048   1.72655 -14.792426  -35.152992  -59.469883  -84.288 -102.159215 -114.172775 -123.557279 -130.950597 -136.22158  -139.785929 -142.188687 
30.421325   24.932531   17.444529   7.892998    -3.856977   -18.014886  -34.99118   -54.76071   -73.12193   -87.497601  -98.824193  -108.060712 -114.987903 -120.253359 -124.356373 
30.551303   25.391767   18.870906   10.957517   1.538053    -9.535194   -22.598697  -38.389555  -55.208053  -69.556258  -81.254268  -90.739807  -98.322417  -104.256711 -108.853733 
30.664703   25.675715   19.70439    12.733737   4.693012    -4.564309   -15.382383  -28.781825  -44.015781  -57.405663  -68.654996  -78.136226  -85.96381   -92.262205  -97.271558  
30.727753   25.865955   20.238259   13.853267   6.664413    -1.448761   -10.800537  -22.615818  -36.367379  -48.848877  -59.549314  -68.920612  -76.813046  -83.32022   -88.600393  
30.865921   26.241471   21.290271   16.08672    10.626372   4.839985    -1.602854   -9.43494    -18.83834   -28.636958  -37.691591  -45.92364   -53.263184  -59.60791   -64.797286  
31.095974   26.462957   21.68939    16.805136   11.820302   6.696608    1.18386 -5.121618   -12.593724  -20.872655  -28.902156  -36.190138  -42.81756   -48.711318  -53.733812  
31.46129    26.783809   22.050232   17.24325    12.414941   7.549917    2.463171    -3.126318   -9.525282   -16.772883  -24.024533  -30.735935  -36.907371  -42.495141  -47.386621  
31.84872    27.13964    22.399963   17.609472   12.824883   8.054302    3.167199    -2.022925   -7.798272   -14.333423  -20.98601   -27.322197  -33.20454   -38.422392  -43.441491  
32.321379   27.611153   22.830246   18.00384    13.186564   8.407782    3.614684    -1.377083   -6.778505   -12.763999  -18.950497  -24.996769  -30.700952  -36.002519  -40.845001  
32.912865   28.117376   23.297908   18.414747   13.541529   8.720016    3.953985    -0.893617   -6.030829   -11.646948  -17.480042  -23.272051  -28.818368  -34.05723   -38.898901  
33.461235   28.733026   23.846096   18.900341   13.945926   9.043626    4.247023    -0.554529   -5.54091    -10.874341  -16.437732  -22.017734  -27.450488  -32.671967  -37.55842   
34.20239    29.399207   24.450979   19.429789   14.378361   9.384043    4.50818 -0.228657   -5.110888   -10.256221  -15.598685  -20.988768  -26.283234  -31.452038  -36.351057  
34.914372   30.186026   25.182228   20.081931   14.90649    9.757508    4.793411    -0.022121   -4.818618   -9.801554   -14.977042  -20.209359  -25.40338   -30.537892  -35.491473  
35.805782   31.056782   26.042754   20.849744   15.526359   10.206612   5.079032    0.217373    -4.533031   -9.394064   -14.424973  -19.520352  -24.601559  -29.643549  -34.578382  
36.912236   32.230447   27.190092   21.88521    16.388134   10.852426   5.512241    0.53729 -4.252576   -9.060047   -13.988674  -18.990227  -23.997652  -28.971069  -33.911535  
38.220177   33.55963    28.522922   23.132328   17.438377   11.652987   6.043032    0.901   -3.941164   -8.721107   -13.565417  -18.470008  -23.400995  -28.283206  -33.172001  
40.089435   35.460059   30.362062   24.861205   18.933028   12.805265   6.809413    1.39481 -3.583199   -8.390298   -13.200262  -18.057954  -22.938035  -27.768679  -32.61952   
42.604155   38.034489   32.852205   27.179704   21.024509   14.456797   7.936568    2.129503    -3.092501   -7.988163   -12.808929  -17.635859  -22.475901  -27.255258  -32.039299  
46.740509   42.104713   36.736597   30.755343   24.224614   17.087908   9.853802    3.360219    -2.293161   -7.426018   -12.358482  -17.254878  -22.122863  -26.910174  -31.65453   
53.63405    48.823341   43.145538   36.706073   29.56244    21.689267   13.405102   5.735263    -0.786028   -6.417941   -11.659605  -16.769755  -21.760135  -26.617262  -31.321544  
66.719783   61.669457   55.479065   48.279934   40.173712   31.232975   21.372923   11.406692   2.961089    -3.87916    -10.044617  -15.840246  -21.29497   -26.408778  -31.159668  
81.066195   75.939181   69.61686    62.097845   53.400235   43.453173   31.99206    19.510149   8.697597    0.08383 -7.513168   -14.397559  -20.598789  -26.139851  -31.007816  
88.630566   83.616297   77.408061   69.893348   60.994658   50.53292    38.266849   24.550308   12.460448   2.685077    -5.844277   -13.434216  -20.125472  -25.947463  -30.897252  
98.70275    93.957875   87.989331   80.562783   71.487536   60.477972   47.235774   32.081579   18.171011   6.62184 -3.316554   -11.987794  -19.434567  -25.69812   -30.791197  
112.445855  108.177395  102.579509  95.384179   86.396863   75.206226   61.200302   44.511365   27.603038   13.116663   0.853254    -9.609617   -18.315011  -25.317822  -30.657122  
129.953349  126.729465  122.16493   115.888176  107.735583  97.599944   84.78044    67.007035   45.133323   25.293443   8.703572    -5.123796   -16.206876  -24.614329  -30.421939  
146.979281  145.477655  143.182354  139.720174  134.892754  128.593272  119.228637  104.230568  81.016758   53.376624   27.161422   5.354242    -11.477492  -23.316319  -30.26605];

我已经删除了左侧的第一列,它似乎与您提供的屏幕截图不匹配。
这是由surf提供的数据

[sz2 sz1]=size(E)
x_range=[-floor(sz1/2):1:floor(sz1/2)];
y_range=[-floor(sz2/2):1:floor(sz2/2)];
[X,Y,Z]=meshgrid(x_range,y_range,0);

figure(1)
ax1=gca
hs1=surf(ax1,X,Y,E)

hs1.EdgeColor='none'
xlabel('X');ylabel('Y');
grid on
title('surf(data)')

直接使用surf不添加点,着色的表面正在渲染,可以使用hs1句柄查看surf生成的点数,以此为surf输出

hs1 = 
  Surface with properties:

       EdgeColor: 'none'
       LineStyle: '-'
       FaceColor: 'flat'
    FaceLighting: 'flat'
       FaceAlpha: 1
           XData: [29×15 double]
           YData: [29×15 double]
           ZData: [29×15 double]
           CData: [29×15 double]

29x15我们付出什么,就得到什么。

**2.-**在MatLab中,将曲面拟合到3D数据的默认命令是griddata

适用于此处

% define finer grid
dx=.01
nx=(x_range(end)+1-(x_range(1)-1))/dx
x_range2=linspace(x_range(1)-1,x_range(end)+1,nx);
y_range2=linspace(y_range(1)-1,y_range(end)+1,nx);
[xq,yq,zq]=meshgrid(x_range2,y_range2,0);

% yq=linspace(y_range(1)-1,y_range(end)+1,nx);
E_range=linspace(min(E,[],'all'),max(E,[],'all'),nx);
% 

Eq=griddata(X,Y,E,xq,yq);
% Eq = griddata(x_range,y_range,E_range,E,xq,yq,zq);

figure(2)
ax2=gca
plot3(ax2,X,Y,E,'ro')
hold on
hs2=surf(ax2,xq,yq,Eq)

hs2.EdgeColor='none'
xlabel('X');ylabel('Y');
grid on
title('griddata(data)')

现在,此surf中的控制柄hs2包含将曲面拟合到29X15(435)点时生成的所有附加点。
检查

hs2 = 
  Surface with properties:

       EdgeColor: 'none'
       LineStyle: '-'
       FaceColor: 'flat'
    FaceLighting: 'flat'
       FaceAlpha: 1
           XData: [1600×1600 double]
           YData: [1600×1600 double]
           ZData: [1600×1600 double]
           CData: [1600×1600 double]

**4.-**根据所使用的MatLab版本,还可以使用命令fit来将曲面拟合到3D点。
4.1.-fit选项poly11使用简单的线性多项式曲线f1_poly11(x,y) = p00 + p10*x + p01*y

x1=X(:); 
y1=Y(:); 
E1=E(:);

% 'poly11' Linear polynomial curve
%      f1_poly11(x,y) = p00 + p10*x + p01*y
f1_poly11 = fit([x1 y1],E1,"poly11")
figure(3)
plot(f1_poly11,[x1 y1],E1)
title('E fit with poly11')
% poly coefficients available here
f1_poly11.p00
f1_poly11.p10
f1_poly11.p01

正如预期的那样,线性近似并不是最适合所提供的点。

**4.2.-**线性插值法做得很好

f1_linint = fit([x1 y1],E1,"linearinterp")
figure(4)
plot(f1_linint,[x1 y1],E1)
title('E fit with linearinterp')
% poly coefficients available here
f1_linint.p

**4.3.-**选项cubicinterp是分段三次插值法

f1_cbint = fit([x1 y1],E1,"cubicinterp")
figure(5)
plot(f1_cbint,[x1 y1],E1)
title('E fit with cubicinterp')
% poly coefficients available here
f1_cbint.p

**4.4.-**选项lowess是局部线性回归

f1_low = fit([x1 y1],E1,"lowess")
figure(6)
plot(f1_low,[x1 y1],E1)
title('E fit with lowess')
% poly coefficients available here
f1_low.p.Degree
f1_low.p.Lambda

又一次,这种回归没有预期的那么好,是吗?

**4.5.-**和poly23是您使用以下表达式对nlinfit使用的类似近似值:

f1_poly23(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 + p21*x^2*y + p12*x*y^2 + p03*y^3

MatLab返回一个可信区间,始终赞赏具有95%置信限的系数。

f1_poly23 = fit([x1 y1],E1,"poly23")
figure(7)
plot(f1_poly23,[x1 y1],E1)
title('E fit with poly23')
% poly coefficients available yere
f1_poly23.p00
f1_poly23.p10
f1_poly23.p01
f1_poly23.p20
f1_poly23.p11
f1_poly23.p02
f1_poly23.p21
f1_poly23.p12
f1_poly23.p03

**5.-**所以griddata非常擅长拟合曲线。

我想提一下这一点,因为

hs2.XData
hs2.YData
hs2.ZData

已经包含了逼近曲面的所有点,真的需要多项式吗?
它可能更容易和更快地生成曲面,然后无论您的编码是关于什么,只需读取和处理存储的点的数据。

补充评论

这里有由John D‘Errico提供的名为gridfitgriddata的改进版本
https://uk.mathworks.com/matlabcentral/fileexchange/8998-surface-fitting-using-gridfit?s_tid=srchtitle_surface%20fitting_2
如果您觉得这个答案有用,请您考虑点击接受的答案。
谢谢

相关问题