| 5 | 1/1 | 返回列表 |
| 查看: 2855 | 回復: 17 | ||
| 當前只顯示滿足指定條件的回帖,點擊這里查看本話題的所有回帖 | ||
wangjunyahit銀蟲 (初入文壇)
|
[求助]
求Matlab高手解決線性方程組的迭代求解問題
|
|
|
遇到一個線性方程組Ax=b的求解問題,使用Matlab直接求解但不確定結果是否正確, 想使用迭代解法求解驗證結果,但苦于找不到合適的迭代解法和程序,希望各位大神 給予幫助,感激涕零。! 方程組是這樣的: A=[-1.2e-21,1.4e6,1.4e6,-1.4e6,1.3e6; 8.9e-22,-1.4e6,4.9e3,3.8e3,0; 1.8e-22,1.4e3,-1.4e6,4.3e3,0; 4.4e-23,3.2e2,1.2e3,-5.1e6,4.3e3; 5.3e-23,0,0,1.3e3,-2.3e6] b=[0;-1.8e-4;-1.3e-2;-1.5e-2;-4.0e-3] 直接求解如下: x=A\b; x=[ 1.029393177754837e+20 6.565808888911404e-08 2.259822851544940e-08 3.842185487752932e-09 4.113382036189007e-09] rcond(A)=1.694258513618419e-29;矩陣A可逆的條件數(shù)估值接近0,矩陣A條件不好,得到的解有誤差 希望各位大神 給予幫助,感激涕零!。 ~EZ9ND[(A@F3IUUY9EJVQ4C.jpg [ Last edited by wangjunyahit on 2012-11-24 at 16:10 ] |

銀蟲 (初入文壇)

新蟲 (初入文壇)
|
你學過數(shù)值分析沒有,這個可以用高斯迭代法和雅可比迭代法求解,不過雖然用迭代法,跑程序時還是有警告,可能求解還是不是非?煽,我求解了一個,下面我把高斯迭代法那個我求解用的程序和運行結果貼在下面: function gsdd(A,b,x0,fs,wucha,ddcs) D=diag(diag(A)); U=-triu(A,1); L=-tril(A,-1); ljzx=inv(A)*b'; if det(D)==0 disp('對角矩陣D奇異,迭代不能實現(xiàn)'); return end B=(D-L)\U;f=(D-L)\b'; for k=1:ddcs x1=B*x0'+f; epsilon=norm(x1-x0',fs); wcx=norm(x1-x0',fs)/(norm(x1,fs)+eps); x0=x1'; if (epsilon end end if (epsilon>wucha)||(wcx>wucha)||k==ddcs disp(' 超過給定最大迭代次數(shù),可能不收斂 ') return end disp('迭代次數(shù):'); k disp('迭代結果:'); x=x0' disp('逆矩陣求解結果:'); x=ljzx end >> A=[-1.2e-21,1.4e6,1.4e6,-1.4e6,1.3e6; 8.9e-22,-1.4e6,4.9e3,3.8e3,0; 1.8e-22,1.4e3,-1.4e6,4.3e3,0; 4.4e-23,3.2e2,1.2e3,-5.1e6,4.3e3; 5.3e-23,0,0,1.3e3,-2.3e6]; >> b=[0;-1.8e-4;-1.3e-2;-1.5e-2;-4.0e-3]'; >> x0=[1 1 1 1 1]; >> gsdd(A,b,x0,1,10^(-15),1000) Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.694259e-029. > In gsdd at 5 Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.352941e-028. > In gsdd at 10 Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.352941e-028. > In gsdd at 10 迭代次數(shù): k = 527 迭代結果: x = 1.029393177754839e+020 6.565808888911417e-008 2.259822851544943e-008 3.842185487752933e-009 4.113382036189012e-009 逆矩陣求解結果: x = 1.029393177754837e+020 6.565808888911401e-008 2.259822851544940e-008 3.842185487752931e-009 4.113382036189006e-009 |

銀蟲 (初入文壇)

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 285求調劑 +5 | AZMK 2026-03-30 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 083000環(huán)境科學與工程調劑,總分281 +4 | 橙子(勝意) 2026-03-30 | 4/200 |
|
|
[考研] 285求調劑 +6 | AZMK 2026-03-29 | 9/450 |
|
|
[考研] 一志愿:西北大學,英一數(shù)一408-284分求調劑 +5 | 12.27 2026-03-27 | 5/250 |
|
|
[考研] 一志愿廈門大學材料工程專碩354找調劑。! +5 | 貝唄鋇鋇 2026-03-30 | 5/250 |
|
|
[考研] 298求調劑 +3 | 什么是胖頭魚 2026-03-30 | 5/250 |
|
|
[考研] 本科211生物醫(yī)學工程085409求調劑339分 +3 | 里子木yy 2026-03-29 | 3/150 |
|
|
[考研] 化學308分調劑 +7 | 你好明天你好 2026-03-30 | 8/400 |
|
|
[考研] 337求調劑 +6 | 《樹》 2026-03-29 | 6/300 |
|
|
[考研] 317求調劑 +10 | 蛋黃咸肉粽 2026-03-26 | 10/500 |
|
|
[考研] 材料與化工304求B區(qū)調劑 +4 | 邱gl 2026-03-26 | 7/350 |
|
|
[考研] 295求調劑 +5 | wei-5 2026-03-26 | 5/250 |
|
|
[考研] 290求調劑 +3 | dfffsar 2026-03-29 | 3/150 |
|
|
[考研]
|
nnnnnnn5 2026-03-25 | 11/550 |
|
|
[考研] 343求調劑 +5 | 愛羈絆 2026-03-28 | 5/250 |
|
|
[考研] 286求調劑 +12 | PolarBear11 2026-03-26 | 12/600 |
|
|
[考研] 調劑 +3 | 好好讀書。 2026-03-28 | 3/150 |
|
|
[考研] 求b區(qū)院校調劑 +4 | 周56 2026-03-24 | 5/250 |
|
|
[考研] 300分,材料,求調劑,英一數(shù)二 +5 | 超贊的 2026-03-24 | 5/250 |
|
|
[考研]
|
黃粱一夢千年 2026-03-24 | 3/150 |
|