MATLAB函数拟合使用
生活随笔
收集整理的這篇文章主要介紹了
MATLAB函数拟合使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 函數命令擬合
最常用的函數擬合命令為fit,語法為|
[擬合結果 擬合精度]=fit(X數據,Y數據,‘擬合類型’)
其中,具體的擬合類型可以參看幫助文檔,也可以使用fittype來自定義新的函數類型,比如定義擬合函數a*x+b*x^2+exp(4*x);|
newtype=fittype('a*x+b*x^2+exp(4*x)') ; fit(x,y,newtype);x=[1;2;3;4;5]; y=[2;3;4;5;6];2 使用界面啟動擬合工具箱
具體操作步驟
3 界面介紹
- 頂部為常用工具欄,常用的一般有誤差分析和鼠標標記坐標點
- Fit Options可以選擇擬合類型和函數次數
- 左側Results顯示了擬合結果的性能參數
- 底部的table of fits可以對多個不同的擬合結果進行性能比較
4 擬合類型
| Custom Equations | 用戶自定義的函數類型 |
| Exponential | exp指數逼近,有2種類型, a*exp(b*x)、 a*exp(b*x) + c*exp(d*x) |
| Fourier | 傅立葉逼近,有7種類型,基礎型是 a0 + a1*cos(x*w) + b1*sin(x*w) |
| Gaussian | 高斯逼近,有8種類型,基礎型是 a1*exp(-((x-b1)/c1)^2) |
| Interpolant | 插值逼近,有4種類型,linear、nearest neighbor、cubic spline、shape-preserving |
| Polynomial | 多形式逼近,有9種類型,linear ~、quadratic ~、cubic ~、4-9th degree ~ |
| Power | 冪逼近,有2種類型,a*x^b 、a*x^b + c |
| Rational | 有理數逼近,分子、分母共有的類型是linear ~、quadratic ~、cubic ~、4-5th degree ~;此外,分子還包括constant型 |
| Smoothing Spline | 平滑逼近 |
| Sum of Sin Functions | 正弦曲線逼近,有8種類型,基礎型是 a1*sin(b1*x + c1) |
| Weibull | 只有一種,a*b*x^(b-1)*exp(-a*x^b) |
5 擬合結果說明
例如在上面的擬合中,選擇Polynomial類型,Degree選擇3階,Robust選擇Off,得到的Results如下:
Linear model Poly3:f(x) = p1*x^3 + p2*x^2 + p3*x + p4 Coefficients (with 95% confidence bounds):p1 = 0.0007776 (0.0007486, 0.0008066)p2 = -0.121 (-0.1258, -0.1161)p3 = 6.324 (6.055, 6.592)p4 = -107 (-111.9, -102)Goodness of fit:SSE: 0.555R-square: 0.9973Adjusted R-square: 0.9973RMSE: 0.03777其中,Goodness of fit里面的性能指標如圖所示:
| SSE | The sum of squares due to error. This statistic measures the deviation of the responses from the fitted values of the responses. A value closer to 0 indicates a better fit. |
| R-square | The coefficient of multiple determination. This statistic measures how successful the fit is in explaining the variation of the data. A value closer to 1 indicates a better fit. |
| Adjusted R-square | The degree of freedom adjusted R-square. A value closer to 1 indicates a better fit. It is generally the best indicator of the fit quality when you add additional coefficients to your model. |
| RMSE | The root mean squared error. A value closer to 0 indicates a better fit. |
6 參考文獻
http://phylab.fudan.edu.cn/doku.php?id=howtos:matlab:mt1-5
https://www.cnblogs.com/yousun/p/3450676.html
總結
以上是生活随笔為你收集整理的MATLAB函数拟合使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎样让硬盘分区显示整数大小
- 下一篇: 数据库索引是什么?为什么要使用索引?