資源描述:
《用matlab中最小二乘法編程求解》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、有一組關(guān)于M、H的實(shí)驗(yàn)數(shù)據(jù)(附件1.data),已知其符合:分布,請利用最小二乘法編寫程序求三個參數(shù)a、b、c的值(要求:利用MATLAB編程)(20分)解:擬合兩組數(shù)據(jù)M、H,已知,只需確定多項式系數(shù)a、b、c。根據(jù)最小二乘原則,使所求問題成為三元一次函數(shù)S(a,b,c)的極小點(diǎn)問題。由多元函數(shù)取極值的必要條件知a,b,c比為,,的解,即滿足將三元一次線性方程組帶入Matlab,其程序如下:clear>>M=[-1.6087e+04,-1.3986e+04,-1.2029e+04,-1.0000e+04,-7.8986e+03,-6.0145e+03,-3.9855e+0
2、3,-2.0290e+03,-1.0145e+03,-4.3478e+02,0.0000,2.1739e+02,...7.9710e+02,2.0290e+03,4.2029e+03,6.0870e+03,8.0435e+03,1.0000e+04,1.2029e+04,1.4203e+04,1.6087e+04];H=[-7.5164e+01,-7.5531e+01,-7.5548e+01,-7.4174e+01,-7.3844e+01,-7.0035e+01,-6.5878e+01,-6.0678e+01,-4.9209e+01,...-3.1822e+01,1.739
3、1e-01,2.9042e+01,4.6080e+01,5.4069e+01,6.1355e+01,6.5512e+01,6.8626e+01,6.8261e+01,7.0330e+01,...7.0311e+01,7.0991e+01];>>sum(2*M.^2),sum(2*M.^4),sum(2*M.^6),sum(2*M.^8),sum(2*M.^10),sum(2*M.*H),sum(2*M.^3.*H),sum(2*M.^5.*H)ans=3.2966e+009ans=5.7227e+017ans=1.1808e+026ans=2.6408e+034ans=6.
4、1821e+042ans=2.0801e+007ans=3.0495e+015ans=5.9067e+023>>[a,b,c]=solve('3.2966e+009*a+5.7227e+017*b+1.1808e+026*c=2.0801e+007','5.7227e+017*a+1.1808e+026*b+2.6408e+034*c=3.0495e+015','1.1808e+026*a+2.6408e+034*b+6.1821e+042*c=5.9067e+023','a,b,c');>>a=double(a),b=double(b),c=double(c)a=0.01
5、64b=-1.1080e-010c=2.5628e-019