2016-05-09 51 views
0

所以我不清楚......我認爲這個問題太長了。這裏所說:matlab - 非線性eqn的系統不給結果

原來的問題:

ca=3.96; 
c0t(1)=2*ca/10; 
c1t(1)=ca; 
c2t(1)=20/56; 
c3t(1)=20/56; 

syms c0 c1 c2 c3 c4 c5 c6 c7 c8 
eqn1 = c0(1)+c4(1)+c8(1) == c0t(1); 
eqn2 = c1(1)+c4(1)+c5(1)+c6(1)+2*c7(1)+2*c8(1) == c1t(1); 
eqn3 = c2t(1)==c2(1)+c5(1); 
eqn4 = c3t(1)==c3(1)+c6(1)+c7(1)+c8(1); 
eqn5 = c4(1)==c1(1)*c0(1)*10^1.98; 
eqn6 = c5(1)==c1(1)*c2(1)*10^2.25; 
eqn7 = c6(1)==c1(1)*c3(1)*10^4.04; 
eqn8 = c7(1)==c1(1)^2*c3(1)*10^5.38; 
eqn9 = c8(1)==c1(1)^2*c0(1)*c3(1)*10^8.1; 


sol = solve([eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8, eqn9], [c0, c1, c2, c3, c4, c5, c6, c7, c8]); 
c0Sol = sol.c0 
c1Sol = sol.c1 
c2Sol = sol.c2 
c3Sol = sol.c3 
c4Sol = sol.c4 
c5Sol = sol.c5 
c6Sol = sol.c6 
c7Sol = sol.c7 
c8Sol = sol.c8 

,結果是這樣的

c0Sol = 
(...*RootOf(z^9 - (... + (...*z^7)/... - (...*z^6)/... + (...*z^5)/... - (...*z^4)/... + (...*z^3)/... - (...*z^2)/... + ................... 

這有數字和運營了幾頁。最重要的是,我爲這個c0Sol獲得了8個更多的東西,對於其他cxSol也是如此。

我需要的是一個數字,如1.23 * 10 ^(-14)。

EDIT1: 現在我想將其轉換爲fsolve:

root9d.m 
function F = root9d(c0,c1,c2,c3,c4,c5,c6,c7,c8) 
F = [ c0+c4+c8-3.96*2; 
    c1+c4+c5+c6+2*c7+2*c8-3.96; 
    c2+c5-20/56; 
    c3+c6+c7+c8-20/56; 
    c1*c0*10^(198/100)-c4; 
    c1*c2*10^(225/100)-c5; 
    c1*c3*10^(404/100)-c6; 
    c1^2*c3*10^(538/100)-c7; 
    c1^2*c0*c3*10^(81/10)-c8; 
    2*c1(1)+c4(1)+c6(1)-2*c2(1)-3*c3(1)-c6(1)-c0(1) 
]; 
end 

fun = @root9d; 
x0 = [0,0,0,0,0,0,0,0,0]; 
x = fsolve(fun,x0) 

越來越

Error using root9d (line 2) 
Not enough input arguments. 
Error in fsolve (line 219) 
     fuser = feval(funfcn{3},x,varargin{:}); 
Caused by: 
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. 

EDIT2:

我試圖vpasolve現在

ca=3.96; 
c0t(1)=2*ca/10; 
c1t(1)=ca; 
c2t(1)=20/56; 
c3t(1)=20/56; 

syms c0 c1 c2 c3 c4 c5 c6 c7 c8 
[sol_c0, sol_c1, sol_c2, sol_c3, sol_c4, sol_c5, sol_c6, sol_c7, sol_c8] = vpasolve([c0(1)+c4(1)+c8(1) == c0t(1), c1(1)+c4(1)+c5(1)+c6(1)+2*c7(1)+2*c8(1) == c1t(1), c2t(1)==c2(1)+c5(1), c3t(1)==c3(1)+c6(1)+c7(1)+c8(1), c4(1)==c1(1)*c0(1)*10^1.98, c5(1)==c1(1)*c2(1)*10^2.25, c6(1)==c1(1)*c3(1)*10^4.04, c7(1)==c1(1)^2*c3(1)*10^5.38, c8(1)==c1(1)^2*c0(1)*c3(1)*10^8.1], [c0, c1, c2, c3, c4, c5, c6, c7, c8]) 

9個結果這樣

sol_c0 = 
            -2.1773252072885945825011626975607 
            -0.002452126418901470788857646210148 
- 0.18134710731268774000741555758302 - 0.51377486965659220019753505021528i 
            -1.7768042958209364363265199765376 
             1.0547920479103151637363730741365 
            0.0026459489994495584563346427370604 
            0.0006200391937591632994332743093457 
            0.020935185135197845770208454108444 
- 0.18134710731268774000741555758302 + 0.51377486965659220019753505021528i 

做這些sol_cx各有9項結果中的意思是,我只需要9的數字。

無論如何,我很高興我仍然可以寫在MATLAB東西...

謝謝你,丹。

+5

你如何提供所有輸入。我的車有問題...但是我只給你車燈...修理它。 http://stackoverflow.com/help/mcve – Matt

+0

如果您對數字解決方案感興趣,則不要使用符號數學。使用像'fsolve'這樣的數字求解器。 – horchler

+1

說實話,我很驚訝'解決'可以將九個帶有非線性的方程式減少爲一個可解的形式。一般來說,'fsolve'是更好的選擇,特別是如果非線性的程度增加。 – TroyHaskin

回答

0

一個解決我的問題的方式是這樣的,但我希望我會找到一個較短....也是不說,他們應該是陽性對不起....

index = find(sol_c0>=0); 
sol_c0 = sol_c0(index); sol_c1 = sol_c1(index); sol_c2 = sol_c2(index); sol_c3 = sol_c3(index);sol_c4 = sol_c4(index);sol_c5 = sol_c5(index);sol_c6 = sol_c6(index);sol_c7 = sol_c7(index);sol_c8 = sol_c8(index); 

和所有這一切sol_

+0

這樣做的更好方法是http://stackoverflow.com/questions/38554041/matlab-make-if-decide-writing-someting-inside-a-function –

相關問題