MATLAB: Fourier curve fitting tool box

fourier fitting

the answer was :
>> fittedmodel
fittedmodel =
General model Fourier7:
fittedmodel(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) +
a6*cos(6*x*w) + b6*sin(6*x*w) + a7*cos(7*x*w) + b7*sin(7*x*w)
Coefficients (with 95% confidence bounds):
a0 = 1.913e+09 (-3.73e+10, 4.113e+10)
a1 = 0 (-3.648e+10, 3.648e+10)
b1 = -9.029e+09 (-1.196e+11, 1.015e+11)
a2 = -6.146e+09 (-5.674e+10, 4.445e+10)
b2 = 9.712e+09 (-1.149e+11, 1.343e+11)
a3 = 7.322e+09 (-6.562e+10, 8.026e+10)
b3 = -4.598e+09 (-7.131e+10, 6.211e+10)
a4 = -4.212e+09 (-4.974e+10, 4.132e+10)
b4 = 6.232e+08 (-1.539e+10, 1.663e+10)
a5 = 1.318e+09 (-1.401e+10, 1.665e+10)
b5 = 3.42e+08 (-7.882e+08, 1.472e+09)
a6 = -2.065e+08 (-2.861e+09, 2.448e+09)
b6 = -1.563e+08 (-1.367e+09, 1.054e+09)
a7 = 1.136e+07 (-1.651e+08, 1.878e+08)
b7 = 1.927e+07 (-1.601e+08, 1.987e+08)
w = 2.088e-05 (3.112e-06, 3.865e-05)
what is right things about Coefficients(ex (-3.732+10,4.113e+10) (-3.648e+10, 3.648e+10) ….)

Best Answer

when coefficients cross 0 that much, the fitting is having trouble choosing between at least two different configurations. For example if you were fitting a symmetric bimodal distribution then it might not be able to make a decision .
Sometimes in cases like that one of the configurations might be much better than the other but the valley of attraction might be relatively narrow and it might not find it.
What you might need to do is supply starting points for the fitting or else use bounds constraints .