如何用matlab做正弦曲线拟合40
发布网友
发布时间:2023-10-19 18:22
我来回答
共1个回答
热心网友
时间:2024-11-19 22:46
【1】第一步
<br>>>cftool
<br>【2】出现对话框,点击data选x和y
<br>【3】creat data set,然后close
<br>【4】点击fitting,在type of type,选Fourier
<br>选择一个合适的即可。
例如:
>> x=0:0.1:pi
>> y=sin(x+x.^2)
>> plot(x,y,'o-')
用非线性回归,得到
得到
General model Sin8:
f(x) =
a1*sin(b1*x+c1) + a2*sin(b2*x+c2) + a3*sin(b3*x+c3) +
a4*sin(b4*x+c4) + a5*sin(b5*x+c5) + a6*sin(b6*x+c6) +
a7*sin(b7*x+c7) + a8*sin(b8*x+c8)
Coefficients (with 95% confidence bounds):
a1 = 4.36 (-2.007e+010, 2.007e+010)
b1 = 1.643 (-1.371e+009, 1.371e+009)
c1 = 0.4803 (-2.517e+009, 2.517e+009)
a2 = 4.282 (-3.806e+006, 3.806e+006)
b2 = 5.715 (-8.181e+004, 8.182e+004)
c2 = -4.306 (-7.305e+004, 7.305e+004)
a3 = 3.823 (-3.826e+006, 3.826e+006)
b3 = 5.867 (-6.623e+004, 6.624e+004)
c3 = -7.586 (-6.24e+004, 6.238e+004)
a4 = 2.67 (-1.363e+014, 1.363e+014)
b4 = 7.29e-006 (-5.336e+011, 5.336e+011)
c4 = -0.8273 (-5.575e+013, 5.575e+013)
a5 = 2.006 (-2.405e+014, 2.405e+014)
b5 = 0.5948 (-1.429e+013, 1.429e+013)
c5 = -0.5683 (-8.375e+013, 8.375e+013)
a6 = 1.729 (-2.606e+014, 2.606e+014)
b6 = 0.5869 (-1.455e+013, 1.455e+013)
c6 = -0.5213 (-8.638e+013, 8.638e+013)
a7 = -2.189 (-1.781e+009, 1.781e+009)
b7 = 2.225 (-1.048e+008, 1.048e+008)
c7 = -0.8675 (-2.948e+008, 2.948e+008)
a8 = 1.225 (-1.956e+014, 1.956e+014)
b8 = 0.616 (-4.375e+012, 4.375e+012)
c8 = -0.03419 (-1.33e+014, 1.33e+014)
Goodness of fit:
SSE: 0.01188
R-square: 0.9992
Adjusted R-square: 0.9968
RMSE: 0.03854