我利用
matlab下的cftool拟合工具,拟合了得到了一个函数。之后我把这个拟合得到的函数放在matlab的M文件里面运行,想要输出在拟合工具里面得到的函数图,结果输出的图却跟拟合出来的得到的图差很多,这是为什么呢?
这是cftool 里面得到的的函数 f(x) = a0 + a1*cos(x*w) + b1*sin(x*w) +
a2*cos(2*x*w) + b2*sin(2*x*w) + a3*cos(3*x*w) + b3*sin(3*x*w) +
a4*cos(4*x*w) + b4*sin(4*x*w) + a5*cos(5*x*w) + b5*sin(5*x*w)
Coefficients (with 95% confidence bounds):
a0 = 3837 (-2.704e+006, 2.711e+006)
a1 = -3.901e+006 (-1.223e+007, 4.423e+006)
b1 = 1.179e+007 (-1.267e+007, 3.625e+007)
a2 = 8.518e+006 (-7.36e+006, 2.44e+007)
b2 = -1.148e+007 (-3.624e+007, 1.327e+007)
a3 = -6.654e+006 (-1.921e+007, 5.9e+006)
b3 = 4.689e+006 (-6.345e+006, 1.572e+007)
a4 = 2.347e+006 (-2.212e+006, 6.906e+006)
b4 = -7.129e+005 (-2.853e+006, 1.427e+006)
a5 = -3.133e+005 (-9.49e+005, 3.224e+005)
b5 = -7529 (-1.086e+005, 9.359e+004)
w = 6.377e-006 (4.926e-006, 7.829e-006)
以下是我的M文件:
- x=1:100023;
- a0 = 3837;
- a1 = -3.901e+006;
- b1 = 1.179e+007;
- a2 = 8.518e+006;
- b2 = -1.148e+007;
- a3 = -6.654e+006;
- b3 = 4.689e+006;
- a4 = 2.347e+006;
- b4 = -7.129e+005;
- a5 = -3.133e+005;
- b5 = -7529;
- w = 6.377e-006;
- f(x) = a0 + a1*cos(x*w) + b1*sin(x*w) +a2*cos(2*x*w) + b2*sin(2*x*w) + a3*cos(3*x*w) + b3*sin(3*x*w)+a4*cos(4*x*w) + b4*sin(4*x*w) + a5*cos(5*x*w)+b5*sin(5*x*w);
- plot(x,f(x))
复制代码第一张是拟合出来的曲线,第二张根据拟合得到的函数plot出的图像。这两张图也差的太多了吧
在M文件里面值用了这些参数的平均值。请大神指导一下,我这样做为什么不行呢?
-
-
一周热门 更多>