Re: [問題]使用matlab利用牛頓法求解方程式的根已回收

看板MATLAB作者 (幫解MATLAB難題囧)時間16年前 (2009/04/29 21:41), 編輯推噓2(204)
留言6則, 1人參與, 最新討論串3/3 (看更多)
※ 引述《winddoor1227 (小白衣)》之銘言: : A(t) = {A(t0)*e ^ (PR/d +λ)( t-t0 )] + [∫e ^ (-R / 4)*I( t' )*e ^ (PR/d + λ : )( t-t' ) dt'} : I(t')是隨著年份而變的常數 : t'=1966-1970 : 此積分式的意思為: : ∫ e ^ (-R / 4)*I( t' )*e ^ (PR/d + λ)( t-t' ) dt' : = : (e^(-R/4) )*I(1966)*e^(-(PR/d+λ)(t-1966) ) : +(e^(-R/4) )*I(1967)*e^(-(PR/d+λ)(t-1967) ) : +....+(e^(-R/4) )*I(1970)*e^(-(PR/d+λ)(t-1970) ) : 假設 : A(t)= 2300 : A(t0)=4923.8 : t=1970 : t0=1966 : P=1、d=200 : λ=0.023 : I(t')=134、63.5、84.7、49.4、49.4 : 要利用牛頓法求解此題中的 R , : 請問我該怎麼做呢?? 久沒解了.不過我沒用牛頓法(其實要用也是可以啦.我有現成的函數) 以下使用FSOLVE函數(本題為非線性函數) -------------------------------程式內容-------------------------------- function pttex120 clc h1 = fsolve(@specialeqex,0) h2 = fsolve(@specialeqex,10) h3 = fsolve(@specialeqex,100) h4 = fsolve(@specialeqex,-10) function f = specialeqex(R) A=2300; At=4923.8; t=1970; t0=1966; P=1; d=200; lamda=0.023; I=[134 63.5 84.7 49.4 49.4]; f = A - At.*exp(P.*R./d+lamda).*(t-t0)+exp(-R./4)... .*I(1).*exp(-(P.*R./d+lamda).*(t-1966))+exp(-R./4)... .*I(2).*exp(-(P.*R./d+lamda).*(t-1967))+exp(-R./4)... .*I(3).*exp(-(P.*R./d+lamda).*(t-1968))+exp(-R./4)... .*I(4).*exp(-(P.*R./d+lamda).*(t-1969))+exp(-R./4)... .*I(5).*exp(-(P.*R./d+lamda).*(t-1970)); -------------------------------輸出結果-------------------------- Optimization terminated: first-order optimality is less than options.TolFun. h1 = -14.5547 Optimization terminated: first-order optimality is less than options.TolFun. h2 = -14.5547 Optimization terminated: first-order optimality is less than options.TolFun. h3 = -14.5547 Optimization terminated: first-order optimality is less than options.TolFun. h4 = -14.5547 初始起猜值分別為 0 10 100 -10 可以得到有唯一解的結論. -- 數值方法 : 求根值 . ODE系統 . DDE系統. DAE系統. PDE系統 非線性聯立系統. 化工程序控制系統 . 力學系統 RLC 系統 . MCK 系統 . Laplace 轉換 系統 其他 : 工程數學 .微積分.化工程序.輸送現象.化工程序線性控制 Simulator . MATLAB tool box . Simulink . FORTRAN 不會影像處理.....囧> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.9.132.173

04/30 16:19, , 1F
謝謝您的幫忙,真的感激不盡!︿︿
04/30 16:19, 1F

04/30 16:50, , 2F
您好,我有試著把您寫出來的程式碼RUN一遍,可是...
04/30 16:50, 2F

04/30 16:51, , 3F
它顯示Function definitions are permitted at the..
04/30 16:51, 3F

04/30 16:51, , 4F
prompt or in scripts.
04/30 16:51, 4F

04/30 16:53, , 5F
prompt or in scripts.
04/30 16:53, 5F

04/30 16:53, , 6F
??? function f = specialeqex(R);
04/30 16:53, 6F
文章代碼(AID): #19-5a0om (MATLAB)
文章代碼(AID): #19-5a0om (MATLAB)