Prev: AWGN filter
Next: ask about plot
From: bo on 23 Mar 2010 23:59 I wrote below .m file function fitfunc angle_degree=[19.883106831000134,15.427573865321031,9.591923791356935,3.274191669811748,-3.141095641238363,-9.545668398763826,-15.786733683310745,-21.39707840054846,-25.45074879011906,-28.2033898252673,-28.139404119889125]; r=[250.63047240908276,277.98655255245717,295.8054985966285,304.4770147318185,306.04980150295796,306.27070542250686,296.62852796047787,277.08848442329753,248.36231698870907,216.01644613315904,181.82071224148257]; x0=[5,5,5,5]; [x,renorm]=lsqcurvefit(@myfun,x0,angle_degree,r); disp(x); disp(renorm); function F=myfun(x,angle_degree) F=x(1)*exp(x(2)*angle_degree)+x(3)*exp(x(4)*angle_degree) I got Optimization terminated: norm of the current step is less than OPTIONS.TolX. 0.0000 2.2826 0.0000 2.2826 7.5120e+005 I found that x(1)&x(3) are both zero.Anyone got idea about this? Thanks
From: Steven Lord on 24 Mar 2010 10:32 "bo " <bobpong1979(a)hotmail.com> wrote in message news:hoc2mc$1er$1(a)fred.mathworks.com... >I wrote below .m file > function fitfunc > angle_degree=[19.883106831000134,15.427573865321031,9.591923791356935,3.274191669811748,-3.141095641238363,-9.545668398763826,-15.786733683310745,-21.39707840054846,-25.45074879011906,-28.2033898252673,-28.139404119889125]; > r=[250.63047240908276,277.98655255245717,295.8054985966285,304.4770147318185,306.04980150295796,306.27070542250686,296.62852796047787,277.08848442329753,248.36231698870907,216.01644613315904,181.82071224148257]; > x0=[5,5,5,5]; > [x,renorm]=lsqcurvefit(@myfun,x0,angle_degree,r); > disp(x); > disp(renorm); function F=myfun(x,angle_degree) > F=x(1)*exp(x(2)*angle_degree)+x(3)*exp(x(4)*angle_degree) > > I got Optimization terminated: norm of the current step is less > than OPTIONS.TolX. > 0.0000 2.2826 0.0000 2.2826 > 7.5120e+005 > > I found that x(1)&x(3) are both zero.Anyone got idea about this? Thanks I strongly doubt they're both zero -- they are probably just being displayed that way. Type the following command then display x again: format long g Those two coefficients are likely to be very, very small though -- for your first value of angle_degree, which is almost 20, and a value for x(2) around 2.3 the term exp(x(2)*angle_degree) is approximately 5e19 -- to have the result of your function be on the order of 250, x(1) would have to be around 5e-18. Actually, both x(1) and x(3) are probably around half that value, so that each of the exponential terms is roughly 125 and their sum is about 250. Plotting angle_degree versus r, this graph does NOT look like an exponential curve. I think you should change your model to something more appropriate to the shape of the curve -- what that model should be, I can't say. You'll need to choose the model based on your knowledge of the underlying problem. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: AWGN filter Next: ask about plot |