| 查看: 4350 | 回復: 16 | ||||
sunjiahuan銅蟲 (小有名氣)
|
[求助]
matlab求解非線性方程組 已有1人參與
|
|||
|
I1=(1.3403/0.323)*(354.3091/443.6719-lambertw((1.0885e-004/443.6719)*exp((330.7*x1+354.3091)/443.6719)))-x1/(0.323+330.7)+1.019*10^(-6)*(exp(x1/1.3403)-1); I2=(1.3403/0.323)*(349.7334/437.9477-lambertw((1.0744e-004/437.9477)*exp((326.4292*x2+349.7334)/437.9477)))-x2/(0.323+326.4292)+1.019*10^(-6)*(exp(x2/1.3403)-1); I3=(1.3403/0.323)*(337.973/423.2354-lambertw((1.0383e-004/423.2354)*exp((315.4524*x3+337.973)/423.2354)))-x3/(0.323+315.4524)+1.019*10^(-6)*(exp(x3/1.3403)-1); I4=(1.3403/0.323)*(324.4644/406.3363-lambertw((9.9677e-005/406.3363)*exp((302.844*x4+324.4644)/406.3363)))-x4/(0.323+302.844)+1.019*10^(-6)*(exp(x4/1.3403)-1); I5=1.019*10^(-6)*(exp(x5/1.3403)-1); 上面是5個方程,I1=f(x1),I2=f(x2),I3=f(x3),I4=f(x4),I5=f(x5); 關于方程里的lambertw函數(shù),可以在附件(太陽電池I-V方程顯示求解原理研究及應用中的第二章中找到)。 而要求解的方程組是由它們5個組成的,如下: x1+x2+x3+x4+x5-30=0 I1-I2=0; I1-I3=0; I1-I4=0; I1-I5=0; 上面的方程組已經寫好,在fun.m里。 而在dfun.m 中是方程組里的每一個方程分別對x1,x2 x3 x4 x5 求一階導數(shù)。其實就是求方程組的雅克比矩陣; 在newton.m里是求解的編程,是我在這個網(wǎng)上(http://hi.baidu.com/aillieo/blog ... c9a59647106493.html)找到的,只是把里面的方程及相關部分改了一下。 我在matlab里輸入newton([0.01 0.01 0.01 0.01 0.01],0.00001,200) 最后得到的結果是 In newton at 6 Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. > In newton at 6 ans = NaN NaN NaN NaN NaN。 這種方法是好多學者用過的,得到的結果都挺好。所以方法應該沒問題。因為我的matlab只學了個皮毛,不知道這里面哪出錯了,還請各位高手給指點一下。 |
材料+新能源+催化+外語 |
榮譽版主 (著名寫手)
![]() |
專家經驗: +4 |
|
錯誤提示信息是矩陣奇異, 可能初值不太合適 我用自帶fsolve解了下 結果不是很好 [/code] function aa [X,FVAL,EXITFLAG,OUTPUT] =fsolve(@fun,[18.7783 0.01 18.1315 18.0062 -2],optimset('MaxFunEvals',1000)) function f=fun(x) x1=x(1); x2=x(2); x3=x(3); x4=x(4); x5=x(5); f1=x1+x2+x3+x4+x5-30; f2=4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(x1/1.3403)-1)-4.1495*(0.7986-lambertw(2.4533e-007*exp((326.4292*x2+349.7334)/437.9477)))+x2/(0.323+326.4292)-1.019*10^(-6)*(exp(x2/1.3403)-1); f3=4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(x1/1.3403)-1)-4.1495*(0.7985-lambertw(2.4532e-007*exp((315.4524*x3+337.973)/423.2354)))+x3/(0.323+315.4524)-1.019*10^(-6)*(exp(x3/1.3403)-1); f4=4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(x1/1.3403)-1)-4.1495*(0.7985-lambertw( 2.4531e-007*exp((302.844*x4+324.4644)/406.3363)))+x4/(0.323+302.844)-1.019*10^(-6)*(exp(x4/1.3403)-1); f5=4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(x1/1.3403)-1)-1.019*10^(-6)*(exp(x5/1.3403)-1); f=[f1 f2 f3 f4 f5]; [/code] Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 1000 (the selected value). X = 18.7895 19.0894 19.0963 19.1094 -46.0868 FVAL = -0.0022 -0.0180 -0.0172 -0.0175 2.7252 EXITFLAG = 0 OUTPUT = iterations: 180 funcCount: 1001 algorithm: 'trust-region dogleg' firstorderopt: 0.0022 message: [1x143 char] |

榮譽版主 (著名寫手)
![]() |
專家經驗: +4 |
|
存為.m文件 命令窗口 >> syms x1 x2 x3 x4 x5 >> F=[x1+x2+x3+x4+x5-30; 4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(-x1/1.3403)-1)-4.1495*(0.7986-lambertw(2.4533e-007*exp((326.4292*x2+349.7334)/437.9477)))+x2/(0.323+326.4292)-1.019*10^(-6)*(exp(-x2/1.3403)-1); 4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(-x1/1.3403)-1)-4.1495*(0.7985-lambertw(2.4532e-007*exp((315.4524*x3+337.973)/423.2354)))+x3/(0.323+315.4524)-1.019*10^(-6)*(exp(-x3/1.3403)-1); 4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(-x1/1.3403)-1)-4.1495*(0.7985-lambertw( 2.4531e-007*exp((302.844*x4+324.4644)/406.3363)))+x4/(0.323+302.844)-1.019*10^(-6)*(exp(-x4/1.3403)-1); 4.1495*(0.7986-lambertw(2.4534e-007*exp((330.7*x1+354.3091)/443.6719)))-x1/331.0230+1.019e-6*(exp(-x1/1.3403)-1)-1.019*10^(-6)*(exp(x5/1.3403)-1)]; [r,n]=mulNewton(F,[18.7783 0.01 18.1315 18.0062 -2]) Warning: Matrix is singular to working precision. > In mulNewton at 17 r = NaN NaN NaN NaN NaN n = 2 [r,n]=mulNewton(F,[18.7783 20 18.1315 18.0062 -20]) r = 20.0741 20.0739 20.0728 20.0718 -50.2925 n = 5 |

榮譽版主 (著名寫手)
![]() |
專家經驗: +4 |
|
將上述代碼拷到editor里面,存為.m文件,點擊editor中run按鈕 結果如下 Equation solved. fsolve completed because the vector of function values is near zero as measured by the default value of the function tolerance, and the problem appears regular as measured by the gradient. X = 20.0741 20.0739 20.0728 20.0718 -50.2925 FVAL = 1.0e-007 * 0.0000 -0.8502 -0.8544 -0.8544 -0.8544 EXITFLAG = 1 OUTPUT = iterations: 13 funcCount: 74 algorithm: 'trust-region dogleg' firstorderopt: 4.6500e-007 message: [1x695 char] |

榮譽版主 (著名寫手)
![]() |
專家經驗: +4 |

銅蟲 (小有名氣)
銅蟲 (小有名氣)
銅蟲 (小有名氣)
鐵桿木蟲 (職業(yè)作家)
鐵桿木蟲 (著名寫手)
ส็็็

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 310求調劑 +10 | 爭取九點睡 2026-03-30 | 10/500 |
|
|---|---|---|---|---|
|
[考研] 342求調劑 +4 | 加油a李zs 2026-03-26 | 4/200 |
|
|
[考研] 考研調劑 +5 | Sanmu-124 2026-03-26 | 5/250 |
|
|
[考研] 0703化學 +14 | 妮妮ninicgb 2026-03-27 | 14/700 |
|
|
[考研] 317求調劑 +10 | 蛋黃咸肉粽 2026-03-26 | 10/500 |
|
|
[考研] 318一志愿吉林大學生物與醫(yī)藥 求調劑 +5 | 篤行致遠. 2026-03-28 | 5/250 |
|
|
[考研] 275求調劑 +15 | Micky11223 2026-03-25 | 20/1000 |
|
|
[考研] 294分080500材料科學與工程求調劑 +8 | 柳溪邊 2026-03-26 | 8/400 |
|
|
[考研] 291求調劑 +5 | Y-cap 2026-03-29 | 6/300 |
|
|
[考研] 材料學碩333求調劑 +11 | 北道巷 2026-03-24 | 11/550 |
|
|
[考研] 一志愿北化085600材料專碩275|有文章專利|求調劑 +7 | Micky11223 2026-03-25 | 7/350 |
|
|
[考研] 復試調劑 +3 | raojunqi0129 2026-03-28 | 3/150 |
|
|
[考研] 調劑 +4 | 柚柚yoyo 2026-03-26 | 4/200 |
|
|
[考研] 0703化學求調劑 +3 | 丹青奶蓋 2026-03-26 | 5/250 |
|
|
[考研] 081200-11408-276學碩求調劑 +3 | 崔wj 2026-03-26 | 3/150 |
|
|
[考研] 一志愿 南京郵電大學 288分 材料考研 求調劑 +3 | jl0720 2026-03-26 | 3/150 |
|
|
[考研] 303求調劑 +6 | 藍山月 2026-03-25 | 6/300 |
|
|
[考研] 求b區(qū)院校調劑 +4 | 周56 2026-03-24 | 5/250 |
|
|
[考研] 【2026考研調劑】制藥工程 284分 求相關專業(yè)調劑名額 +4 | 袁奐奐 2026-03-25 | 8/400 |
|
|
[考研] 086003食品工程求調劑 +6 | 淼淼111 2026-03-24 | 6/300 |
|