推 fourmis:感謝 01/14 22:49
※ 引述《fourmis (Chivalry)》之銘言:
: 我想要解一個6元2次方程組
: A11^2+A12^2=711.5497
: A11*A21+A12*A22=-11.6305
: A11*A31+A12*A32=-105.0091
: A21^2+A22^2=161.861
: A21*A31+A22*A32=43.8431
: A31^2+A32^2=15.5254
: 程式碼如下
: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
: eq1='A11^2+A12^2-711.5497';
: eq2='A11*A21+A12*A22+11.6305';
: eq3='A11*A31+A12*A32+105.0091';
: eq4='A21^2+A22^2-161.861';
: eq5='A21*A31+A22*A32-43.8431';
: eq6='A31^2+A32^2-15.5254';
: [A11 A21 A31 A12 A22 A32]=
: solve(eq1,eq2,eq3,eq4,eq5,eq6,'A11','A21','A31','A12','A22','A32');
: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
: 執行的結果會出現Explicit solution could not be found
: 請問有甚麼比較好的作法可以解出答案呢?
這種的非線性方程式.不容易解出解析解.
不過大部份可以找到數值解.
數值解程式碼如下:
==============================================================================
function pttex39
% x=[a11 a12 a21 a22 a31 a32]
a=fsolve(@pttnol,[1 2 3 4 5 6])
function f=pttnol(x)
f=zeros(6,1);
f(1)=x(1).^2+x(2).^2 -711.5497;
f(2)=x(1).*x(3)+x(2).*x(4) +11.6305;
f(3)=x(1).*x(5)+x(2).*x(6) +105.0091;
f(4)=x(3).^2+x(4).^2 -161.861;
f(5)=x(3).*x(5)+x(4).*x(6) -43.8431;
f(6)=x(5).^2+x(6).^2 -15.5254;
==============================================================================
執行後的結果為:
Optimizer appears to be converging to a point which is not a root.
Relative function value changing by less than max(options.TolFun^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.
TolFun)
Try again with a new starting guess.
a =
3.2150 26.4835 12.5845 -1.9876 2.5132 -4.1824
應該是唯一解.
--
數值方法 : 求根值 . ODE系統 . DDE系統. DAE系統. PDE系統
非線性聯立系統. 化工程序控制系統 . 力學系統
RLC 系統 . MCK 系統 . Lalpace 轉換 系統
其他 : 工程數學 .微積分.化工程序.輸送現象.化工程序線性控制
Simulator . MATLAB tool box . Simulink . FORTRAN
不會影像處理.....囧>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.160.163