| 1 | 1/1 | 返回列表 |
| 查看: 2465 | 回復(fù): 0 | ||
mayaya26木蟲 (小有名氣)
|
[求助]
請教大家一個MATLAB求解四元一次方程組的問題
|
|
編程中里面存在方程組fun_2,方程組中的未知量為 x y theta theta1 ,我嘗試用簡單的牛頓法求解,好像不行,求各位高手相助。謝謝 程序如下: function f=fun_2(x) d=0.4;epsilong=9; xt=-0.5;xr1=0.5;L=5; syms x y theta theta1 phi=asin(sin(theta)./sqrt(epsilong)); phi1=asin(sin(theta1)./sqrt(epsilong)); Lt=d/cos(phi); L1=d/cos(phi1); Ltt=(y-d)/cos(theta); L11=(y-d)/cos(theta1); f1=(x-xt)^2+y^2-(Lt^2+Ltt^2 +2*Lt*Ltt*cos(theta - phi)); f2=(x-xr1)^2+y^2-(L1^2+L11^2 +2*L1*L11*cos(theta1 - phi1)); f3=L-sqrt(epsilong)*Lt+Ltt+sqrt(epsilong)*L1+L11; f=[f1 f2 f3]; end function df=dfun_2(x) syms x y theta theta1 f=fun_2(x); df=[diff(f,'x');diff(f,'y');diff(f,'theta');diff(f,'theta1')]; df=conj(df'); end function x=newton_2(x0,eps,N) con=0; % syms x y theta theta1 %其中x0為迭代初值eps為精度要求N為最大迭代步數(shù)con用來記錄結(jié)果是否收斂 for i=1:N; x0=[0 1 0.5 0.4];eps=1.0e-3;N=10; for i=1:N; f=subs(fun_1(x0),{'x' 'y' 'theta' 'theta1'},{x0(1) x0(2) x0(3) x0(4)}); df=subs(dfun_1(x0),{'x' 'y' 'theta' 'theta1'},{x0(1) x0(2) x0(3) x0(4)}); x=x0-f/df; for j=1:length(x0) il(i,j)=x(j); end if norm(x-x0)<eps con=1; break; end x0=x; end 運行結(jié)果: newton_2 Error using mupadmex Error in MuPAD command: Out of memory. Error in sym/privBinaryOp (line 1506) Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:}); Error in sym/mrdivide (line 237) X = privBinaryOp(A, B, 'symobj::mrdivide'); Error in newton_2 (line 9) x=x0-f/df; 是哪里出錯了? 大神們幫幫忙,比較急 |
找到一些相關(guān)的精華帖子,希望有用哦~
| 1 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 生物學(xué)學(xué)碩,一志愿湖南大學(xué),初試成績338 +6 | YYYYYNNNNN 2026-03-26 | 7/350 |
|
|---|---|---|---|---|
|
[考研] 一志愿北京理工大學(xué)本科211材料工程294求調(diào)劑 +4 | mikasa的圍巾 2026-03-28 | 4/200 |
|
|
[考研] 復(fù)試調(diào)劑 +3 | raojunqi0129 2026-03-28 | 3/150 |
|
|
[考研] 085600,材料與化工321分求調(diào)劑 +9 | 大饞小子 2026-03-28 | 9/450 |
|
|
[考研] 322求調(diào)劑 +5 | 舊吢 2026-03-24 | 5/250 |
|
|
[考研] 材料與化工(0856)304求B區(qū)調(diào)劑 +8 | 邱gl 2026-03-27 | 8/400 |
|
|
[考研] 085600 286分 材料求調(diào)劑 +7 | 麻辣魷魚 2026-03-27 | 8/400 |
|
|
[考研] 085701環(huán)境工程,267求調(diào)劑 +16 | minht 2026-03-26 | 16/800 |
|
|
[考研] 292求調(diào)劑 +14 | 鵝鵝鵝額額額額?/a> 2026-03-25 | 15/750 |
|
|
[考研] 291求調(diào)劑 +7 | 孅華 2026-03-22 | 7/350 |
|
|
[考研] 考研調(diào)劑 +4 | Sanmu-124 2026-03-26 | 4/200 |
|
|
[考研] 274求調(diào)劑 +17 | 顧九笙要謙虛 2026-03-24 | 23/1150 |
|
|
[考研] 考研化學(xué)308分求調(diào)劑 +10 | 你好明天你好 2026-03-23 | 12/600 |
|
|
[考研] 調(diào)劑 +3 | 李嘉圖·S·路 2026-03-27 | 3/150 |
|
|
[考研] 調(diào)劑推薦 +5 | 清酒714 2026-03-26 | 6/300 |
|
|
[考研] 286求調(diào)劑 +4 | lim0922 2026-03-26 | 4/200 |
|
|
[考研] 求調(diào)劑 +6 | 林之夕 2026-03-24 | 6/300 |
|
|
[考研] 324求調(diào)劑 +8 | hanamiko 2026-03-26 | 10/500 |
|
|
[考研] 材料與化工304求B區(qū)調(diào)劑 +3 | 邱gl 2026-03-26 | 6/300 |
|
|
[考研] 材料考研求調(diào)劑 +3 | Dendel 2026-03-23 | 6/300 |
|