欢迎来到天天文库
浏览记录
ID:15979334
大小:31.50 KB
页数:4页
时间:2018-08-06
《matlab求解超定方程组实例》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Matlab求解超定方程组实例对于超定方程组,特别是非线性方程组,可以用Matlab基于最小二乘算法来进行求解,例如,求解下列方程组:一个三个未知数,九个方程的非线性方程组:cos(x3)*sin(x2)*sin(x1)-sin(x3)*cos(x1)=-0.9944;sin(x3)*sin(x2)*sin(x1)+cos(x3)*cos(x1)=-0.0870;cos(x2)*sin(x1)=-0.0606;cos(x3)*sin(x2)*cos(x1)+sin(x3)*sin(x1)=0.0349;sin(x3)*
2、sin(x2)*cos(x1)-cos(x3)*sin(x1)=-0.8085;cos(x2)*cos(x1)=0.5875;os(x3)*cos(x2)=-0.1001;sin(x3)*cos(x2)=0.5821;-sin(x2)=0.8070;代码%Bylyqmathfunctionmain()clc;clearall;closeall;%cos(x3)*sin(x2)*sin(x1)-sin(x3)*cos(x1)=-0.9944;%sin(x3)*sin(x2)*sin(x1)+cos(x3)*cos(x1)
3、=-0.0870;%cos(x2)*sin(x1)=-0.0606;%cos(x3)*sin(x2)*cos(x1)+sin(x3)*sin(x1)=0.0349;%sin(x3)*sin(x2)*cos(x1)-cos(x3)*sin(x1)=-0.8085;%cos(x2)*cos(x1)=0.5875;%os(x3)*cos(x2)=-0.1001;%sin(x3)*cos(x2)=0.5821;%-sin(x2)=0.8070;x0=[0.30.40.5] [x,resnorm]=lsqn
4、onlin(@test_fun,x0)F=test_fun(x)functionF=test_fun(x)x1=x(1);x2=x(2);x3=x(3);F(1)=cos(x3)*sin(x2)*sin(x1)-sin(x3)*cos(x1)+0.9944;F(2)=sin(x3)*sin(x2)*sin(x1)+cos(x3)*cos(x1)+0.0870;F(3)=cos(x2)*sin(x1)+0.0606;F(4)=cos(x3)*sin(x2)*cos(x1)+sin(x3)*sin(x1)-0.0349;F
5、(5)=sin(x3)*sin(x2)*cos(x1)-cos(x3)*sin(x1)+0.8085;F(6)=cos(x2)*cos(x1)-0.5875;F(7)=cos(x3)*cos(x2)+0.1001;F(8)=sin(x3)*cos(x2)-0.5821;F(9)=-sin(x2)-0.8070;结果x0= 0.3000 0.4000 0.5000Localminimumfound.Optimizationcompletedbecausethesizeofthegradientislessthant
6、hedefaultvalueofthefunctiontolerance.x= -0.1028 -0.9390 1.7411resnorm= 5.4490e-009F= 1.0e-004* Columns1through7 0.3522 0.1842 -0.0442 0.1487 0.2260 -0.0936 0.0183 Columns8through9 -0.3600 -0.4160>> 可以发现,误差在1.0e-004级别,还是可以接受的。
此文档下载收益归作者所有