| 查看: 1454 | 回復: 10 | ||
[求助]
matlab程序問題求解答
|
|
function[c,err,yc]=bisect(f,a,b,delta) % Input - f is the function input as a string 'f' % - a and b are the left and right endpoints % - delta is the tolerance % Output - c is the zero % - yc = f(c) % - err is the error estimate for c ya = feval(f,a); yb = feval(f,b); if ya * yb > 0, end max1 = 1+ round((log(b-a)-log(delta))/log(2)); for k =1:max1 c =(a+b)/2; yc = feval(f,c); if yc==0; a=c; b=c; elseif yb * yc > 0 b=c; yb=yc; else a=c; ya=yc; end if b - a < delta, break, end end c=(a+b)/2; err=abs(b-a); yc=feval(f,c); % 求函數在c處的函數值 for T=200:10:300 K = exp(-9.3932+3204.71/T+0.835931*log(T)... +2.35267*10^-3*T-1.8736*10^-6*T^2+5.1606*10^-10*T^3) f=inline('(4*K-1)*x^2-8*K*x+4*K'); bisect(f,0,1,10^-5) end 主程序調用函數出錯 |
銅蟲 (著名寫手)
|
function problem_solve %-------------------------------------------- disp('----------------分割線-----------------'); %-------------------------------------------- function[c,err,yc]=bisect(f,a,b,delta) % Input - f is the function input as a string 'f' % - a and b are the left and right endpoints % - delta is the tolerance % Output - c is the zero % - yc = f(c) % - err is the error estimate for c ya = feval(f,a); yb = feval(f,b); if ya * yb > 0, end max1 = 1+ round((log(b-a)-log(delta))/log(2)); for k =1:max1 c =(a+b)/2; yc = feval(f,c); if yc==0; a=c; b=c; elseif yb * yc > 0 b=c; yb=yc; else a=c; ya=yc; end if b - a < delta, break, end end c=(a+b)/2; err=abs(b-a); yc=feval(f,c); % 求函數在c處的函數值 end %--------------------------------------------- function f=subfun(x,K) f=(4*K-1).*x.^2-8*K.*x+4*K; end %--------------------------------------------- for T=200:10:300 K = exp(-9.3932+3204.71/T+0.835931*log(T)... +2.35267*10^-3*T-1.8736*10^-6*T^2+5.1606*10^-10*T^3) [c,err,yc]=bisect(@(x)subfun(x,K),0,1,10^-5) disp('----------------分割線-----------------'); end end 樓主,希望能幫助到你。 |

銅蟲 (著名寫手)

銅蟲 (著名寫手)

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 086003食品工程求調劑 +4 | 淼淼111 2026-03-24 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 279分求調劑 一志愿211 +18 | chaojifeixia 2026-03-19 | 20/1000 |
|
|
[考研] 資源與環(huán)境 調劑申請(333分) +6 | holy J 2026-03-21 | 6/300 |
|
|
[考研] 材料專碩英一數二306 +8 | z1z2z3879 2026-03-18 | 8/400 |
|
|
[考研] 化學308分求調劑 +3 | 你好明天你好 2026-03-23 | 3/150 |
|
|
[考研] 0703化學求調劑 +4 | 奶油草莓. 2026-03-22 | 5/250 |
|
|
[考研] 接收2026碩士調劑(學碩+專碩) +4 | allen-yin 2026-03-23 | 6/300 |
|
|
[考研] 求調劑 +5 | Zhangbod 2026-03-21 | 7/350 |
|
|
[考研] 考研調劑 +3 | 呼呼?~+123456 2026-03-21 | 3/150 |
|
|
[考研] 297求調劑 +3 | 喜歡還是不甘心 2026-03-20 | 3/150 |
|
|
[考研] 一志愿深大,0703化學,總分302,求調劑 +4 | 七月-七七 2026-03-21 | 4/200 |
|
|
[考研] 297求調劑 +11 | 戲精丹丹丹 2026-03-17 | 12/600 |
|
|
[考研] 299求調劑 +6 | △小透明* 2026-03-17 | 6/300 |
|
|
[考研] 324分 085600材料化工求調劑 +4 | llllkkkhh 2026-03-18 | 4/200 |
|
|
[考研] 274求調劑 +10 | S.H1 2026-03-18 | 10/500 |
|
|
[考研] 22408 344分 求調劑 一志愿 華電計算機技術 +4 | solanXXX 2026-03-20 | 4/200 |
|
|
[考研] 一志愿中海洋材料工程專碩330分求調劑 +8 | 小材化本科 2026-03-18 | 8/400 |
|
|
[考研] 0817 化學工程 299分求調劑 有科研經歷 有二區(qū)文章 +22 | rare12345 2026-03-18 | 22/1100 |
|
|
[考研] 086500 325 求調劑 +3 | 領帶小熊 2026-03-19 | 3/150 |
|
|
[考研] 材料學碩318求調劑 +5 | February_Feb 2026-03-19 | 5/250 |
|