## 11-3 ODE ?囦护?勯伕??

┮Τ ODE 钡材块跑计縩だ筁祘ノ贺匡兜Options贺 ODE Α

[t, y] = solver('odeFile', [t0, tn], y0, options);

ㄤい options 琌パ odeset ㄓ北挡篶跑计挡篶跑计縩だ筁祘ノ贺匡兜odeset Α

options = odeset('name1', value1, 'name2', value2, )

玻ネ挡篶跑计 optionsㄤ逆 name1  value1逆 name2  value2ㄌ摸崩ゼ砆砞﹚逆ㄤ逆箇砞

иэ跑瞷 options 挡篶跑计い琘逆ㄤΑ

newOptions = odeset(options, 'name', value);

value = odeget(otpions, 'name');

ㄤい name 逆嘿value 癸莱逆

Example 1: 11-盽稬だよ祘Α/odeset01.modeset AbsTol: [ positive scalar or vector {1e-6} ] RelTol: [ positive scalar {1e-3} ] NormControl: [ on | {off} ] NonNegative: [ vector of integers ] OutputFcn: [ function_handle ] OutputSel: [ vector of integers ] Refine: [ positive integer ] Stats: [ on | {off} ] InitialStep: [ positive scalar ] MaxStep: [ positive scalar ] BDF: [ on | {off} ] MaxOrder: [ 1 | 2 | 3 | 4 | {5} ] Jacobian: [ matrix | function_handle ] JPattern: [ sparse matrix ] Vectorized: [ on | {off} ] Mass: [ matrix | function_handle ] MStateDependence: [ none | {weak} | strong ] MvPattern: [ sparse matrix ] MassSingular: [ yes | no | {maybe} ] InitialSlope: [ vector ] Events: [ function_handle ]

AbsTo1タ秖┪秖$10^{-6}$荡癸粇畉甧г

OutputSelま秖场ODE ぇ块跑计ま∕﹚êㄇ块跑计ぇじ盢砆癳块ㄧΑ
Refineタ俱计1┪4 (for ode45)Refine = 2 玻ネㄢ计秖块翴Refine = 3 玻ネ计秖块翴ㄌ摸崩
Statson ┪ offoffStats = 'on' 玻ネ璸衡筁祘贺参璸戈
Jacobian 痻皚ぇ闽逆Jconstanton ┪ offoff狦 Jacobian 痻皚盽计玥 Jconstant = 'on'
Jacobianon ┪ offoff璝F(t, y, 'Jacobian') 肚 $\partial F/\partial y$玥 Jacobian = 'on'
Jpatternon ┪ offoff璝 F([ ], [ ], 'JPattern') 肚 $\partial F/\partial y$ $\partial F/\partial y$ 琌祡波痻皚玥 Jpattem = 'on'
Vectorizedon ┪ offoff璝 F(t, [y1, y2..]) 肚 [F(t,y1), F(t,y2)..]玥 Vectorized = 'on'

Initial Stepタ秖 癬﹍˙某

MassSingularyesno ┪ maybemaybe借秖痻皚琌 Singular
ㄆン祇ネ丁ぇ闽逆Eventson ┪ offoff璝 ODE 郎肚ㄆンㄧΑの闽戈癟玥 Events = 'on'
Ode15s ぇ闽逆MaxOrder1, 2, 3, 4 ┪ 55縩だそΑノ程蔼Ω计
BDFon ┪ offoff璝ㄏノ BDFBackward Differentiation Formula玥 BDF = 'on'

癸碭盽ノ逆ㄓ秈︽弧

f 縩だ粇畉甧гよ–Ω縩だ┮玻ネЫ场粇畉 e(i)ゲ斗骸ìよ祘Α

$$|e(i)| \leq max(RelTol*|y(i)|, AbsTol(i))$$

ㄤい i 材 i 篈跑计и RelTol の AbsTol ㄓ―眔弘絋縩だ挡狦ㄒ

Example 2: 11-盽稬だよ祘Α/odeRelTol01.msubplot(2,1,1); ode45('vdp1', [0 25], [3 3]'); title('RelTol=0.01'); options = odeset('RelTol', 0.00001); subplot(2,1,2); ode45('vdp1', [0 25], [3 3]', options); title('RelTol=0.0001');

瓃絛ㄒい材瓜┮ㄏノ癸粇畉琌0.01箇砞材瓜┮ㄏノ癸粇畉琌0.00001и眔耕灿盞翴┮璸衡丁穦ゑ耕

縩だ块闽矪瞶よи匡ノ OutputFcnㄏ眔讽 ODE ⊿Τ块跑计块ㄧΑ OutputFcn 穦砆 MATLAB ㊣OutputFcn 箇砞琌〃odeplot〃ㄤ礶┮Τ篈跑计ㄤウノㄧΑ临Τ

• odephas2礶 2-D キPhase Plane
• odephas3礶 3-D キ
• odeprint繦跌怠璸衡挡狦

 Lorenz 待≒よ祘ΑLorenz Chaotic Equationㄒㄤ ODE 郎ぇず甧陪ボ

11-盽稬だよ祘Α/lorenzOde.mfunction dy = lorenzOde(t, y) % LORENZODE: ODE file for Lorenz chaotic equation SIGMA = 10.; RHO = 28; BETA = 8./3.; A = [ -BETA 0 y(2) 0 -SIGMA SIGMA -y(2) RHO -1 ]; dy = A*y;

Example 3: 11-盽稬だよ祘Α/odeLorenz01.mode45('lorenzOde', [0 10], [20 5 -5]');

Example 4: 11-盽稬だよ祘Α/odeLorenz02.moptions = odeset('OutputFcn', 'odephas3'); % ㄏノ odephas3 秈︽酶瓜 ode45('lorenzOde', [0 10], [20 5 -5]', options);

瓃瓜い瞷兵Ρ絬Ρ絬篈跑计畒夹丁把计兵丁いΡ絬

Hint

τē安砞и OutputFcn 砞Θ"myFunc"

options = odeset('OutputFcn', 'myFunc')

1. 縩だ秨﹍ODE 穦㊣ myFunc(tspan, y0, 'init') 琵 myFunc 秈︽贺﹍て笆
2. –縩だ˙艼いODE 盢穦尿㊣ status=myFunc(t, y)璝 status=1玥氨ゎ縩だ
3. 縩だ挡ODE 穦㊣ myFunc([], [], 'done')琵 myFunc 秈︽ΜЮ笆
璝и璶縩だ筁祘い玻ネ笆礶碞沮瓃玥ㄓ砞璸 myFunc.m

OutputSel ﹚璶肚癳 OutputFcn 篈跑计ぇじㄒ璝璶肚癳材の材 Lorenz 待≒よ祘Α篈攀计 odeplot块

Example 5: 11-盽稬だよ祘Α/odeOutputSelect01.moptions = odeset('OutputSel', [1,3]); % 礶材㎝材篈跑计 ode45('lorenzOde', [0 10], [20 5 -5]', options);

瓜いи礶材㎝材篈跑计

Refine 逆ㄏノず础猭ㄓ糤块篈跑计盞眔耕キ菲块Ρ絬ㄒいиノ Refine 逆ㄓㄏ ode23 块翴计糤

Example 6: 11-盽稬だよ祘Α/odeRefine01.msubplot(2,1,1); ode23('vdp1', [0 25], [3 3]'); subplot(2,1,2); options = odeset('Refine', 3); ode23('vdp1', [0 25], [3 3]', options);

Example 7: 11-盽稬だよ祘Α/odeShowStats01.m[t, y] = ode45('vdp1', [0 25], [3 3]', odeset('Stat', 'on'));71 successful steps 10 failed attempts 487 function evaluations

参璸计パ ODE 材块跑计肚ㄒ

Example 8: 11-盽稬だよ祘Α/odeShowStats02.m[t, y, s] = ode45('vdp1', [0 25], [3 3]'); ss = 71 10 487 0 0 0

MaxStep の InitialStep 逆ノㄓ秸俱程縩だ˙の癬﹍縩だ˙τē眤ぃゲ秸俱硂ㄢ计 ODE セō碞ㄣΤ˙笆秸続疭眔猔種琌

• 璝璶玻ネ块翴钡秸俱 Refine 逆秸俱 MaxStep 瘤礛笷妓狦琌璸衡丁穦碩糤
• 狦縩だ挡狦ぃ非絋叫づ秸 MaxStep眤莱秸 RelTol の AbsTol秸 MaxStep 琌程˙艼

ㄤウ逆耕ぶノぃ仑瓃Τ砍届弄钡陆綷 MATLAB Τ闽 ODE も

MATLAB祘Α砞璸秈顶絞