Matlab正弦曲线拟合 5
我有一组数据,想通过正弦曲线拟合算法找到最合适的拟合正弦信号哦,再分析其与实际输入原始数据的对比...
我有一组数据,想通过正弦曲线拟合算法找到最合适的拟合正弦信号哦,再分析其与实际输入原始数据的对比
展开
2个回答
展开全部
方法/步骤
运行Matlab软件。
在工作空间中存入变量的实验数据。具体如下:
可以直接用矩阵来存放数据,直接在命令窗口输入
x=[数据x1,数据x2,...,数据xn];
y=[数据y1,数据y2,...,数据yn];
当数据较多时,可以从excel,txt等文件中导入。
把数据存入工作空间后,在命令窗口中输入cftool,回车运行。
在这个拟合工具窗口的左边,选择变量,即分别选择x,y。
选择拟合的曲线类型,一般是线性拟合,高斯曲线,平滑曲线等,根据需要选择。
选择完后会自动完成拟合,并且给出拟合函数表达式。
点击菜单栏中的“file”,选择“print to figure"进行画图。
在图形窗口中,可以对图形显示模式进行修改,如添加标题,坐标名称等。
最后得到比较完整的图形曲线。点击”file"中的“save"进行保存。
追问
我是想通过一组正弦曲线的拟合,找出残差平方和最小,最合适的拟合正弦信号怎么办呢?
展开全部
【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
<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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询