MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of
5 Differential Equations The example solves the equations on [0,5] with history y 1 () t = 1 y 2 () t = 1 y 3 () t = 1 for t ≤ 0 . Note The demo ddex1 contains the complete code for this example. To see the code in an editor, click the example name, or type edit ddex1 at the command line. To run the example type ddex1 at the command line. See “DDE Solver Basic Syntax” on page 5-52 for more information. 1 Rewrite the problem as a first-order system. To use dde23, you must rewrite the equations as an equivalent system of first-order differential equations. Do this just as you would when solving IVPs and BVPs for ODEs (see “Examples: Solving Explicit ODE Problems” on page 5-9). However, this example needs no such preparation because it already has the form of a first-order system of equations. 2 Identify the lags. The delays (lags) τ 1 , …, τ k are supplied to dde23 as a vector. For the example we could use lags = [1,0.2]; In coding the differential equations, τ j = lags(j). 3 Code the system of first-order DDEs. Once you represent the equations as a first-order system, and specify lags, you can code the equations as a function that dde23 can use. This code represents the system in the function, ddex1de. function dydt = ddex1de(t,y,Z) ylag1 = Z(:,1); ylag2 = Z(:,2); 5-54
Initial Value Problems for DDEs dydt = [ylag1(1) ylag1(1) + ylag2(2) y(2) ]; 4 Code the history function. The history function for this example is function S = ddex1hist(t) S = ones(3,1); 5 Apply the DDE solver. The example now calls dde23 with the functions ddex1de and ddex1hist. sol = dde23(@ddex1de,lags,@ddex1hist,[0,5]); Here the example supplies the interval of integration [0,5] directly. Because the history is constant, we could also call dde23 by sol = dde23(@ddex1de,lags,ones(3,1),[0,5]); 6 View the results. Complete the example by displaying the results. dde23 returns the mesh it selects and the solution there as fields in the solution structure sol. Often, these provide a smooth graph. plot(sol.x,sol.y); title('An example of Wille'' and Baker'); xlabel('time t'); ylabel('solution y'); legend('y_1','y_2','y_3',2) 5-55
- Page 138 and 139: 5 Differential Equations odephas3 o
- Page 140 and 141: 5 Differential Equations This secti
- Page 142 and 143: 5 Differential Equations The basic
- Page 144 and 145: 5 Differential Equations 2 Code the
- Page 146 and 147: 5 Differential Equations function.
- Page 148 and 149: 5 Differential Equations One way to
- Page 150 and 151: 5 Differential Equations y0, yp0 Ve
- Page 152 and 153: 5 Differential Equations For exampl
- Page 154 and 155: 5 Differential Equations 1 0.8 0.6
- Page 156 and 157: 5 Differential Equations 2.5 Soluti
- Page 158 and 159: 5 Differential Equations To run thi
- Page 160 and 161: 5 Differential Equations 2 u′ i =
- Page 162 and 163: 5 Differential Equations dydt(i+1,:
- Page 164 and 165: 5 Differential Equations refine = 4
- Page 166 and 167: 5 Differential Equations Example: A
- Page 168 and 169: 5 Differential Equations function [
- Page 170 and 171: 5 Differential Equations Note The R
- Page 172 and 173: 5 Differential Equations 1 Robertso
- Page 174 and 175: 5 Differential Equations The MATLAB
- Page 176 and 177: 5 Differential Equations Summary of
- Page 178 and 179: 5 Differential Equations Problem Si
- Page 180 and 181: 5 Differential Equations Error Tole
- Page 182 and 183: 5 Differential Equations Troublesho
- Page 184 and 185: 5 Differential Equations Function d
- Page 186 and 187: 5 Differential Equations dde23 prod
- Page 190 and 191: 5 Differential Equations solution y
- Page 192 and 193: 5 Differential Equations Example: C
- Page 194 and 195: 5 Differential Equations Changing D
- Page 196 and 197: 5 Differential Equations BVP Functi
- Page 198 and 199: 5 Differential Equations two-point
- Page 200 and 201: 5 Differential Equations The input
- Page 202 and 203: 5 Differential Equations 2 Pass the
- Page 204 and 205: 5 Differential Equations 3 Code the
- Page 206 and 207: 5 Differential Equations Finding Un
- Page 208 and 209: 5 Differential Equations vectorized
- Page 210 and 211: 5 Differential Equations There is a
- Page 212 and 213: 5 Differential Equations 3 Solve on
- Page 214 and 215: 5 Differential Equations hold off T
- Page 216 and 217: 5 Differential Equations Note The d
- Page 218 and 219: 5 Differential Equations legend('An
- Page 220 and 221: 5 Differential Equations Here, v(1-
- Page 222 and 223: 5 Differential Equations solution v
- Page 224 and 225: 5 Differential Equations Note The D
- Page 226 and 227: 5 Differential Equations After disc
- Page 228 and 229: 5 Differential Equations The output
- Page 230 and 231: 5 Differential Equations 2 Code the
- Page 232 and 233: 5 Differential Equations Note See t
- Page 234 and 235: 5 Differential Equations The exampl
- Page 236 and 237: 5 Differential Equations and the ri
5 Differential Equations<br />
The example solves the equations on [0,5] with history<br />
y 1 () t = 1<br />
y 2 () t = 1<br />
y 3 () t = 1<br />
for t ≤ 0 .<br />
Note The demo ddex1 contains the complete code for this example. To see the<br />
code in an editor, click the example name, or type edit ddex1 at the command<br />
line. To run the example type ddex1 at the command line. See “DDE Solver<br />
Basic Syntax” on page 5-52 for more information.<br />
1 Rewrite the problem as a first-order system. To use dde23, you must<br />
rewrite the equations as an equivalent system <strong>of</strong> first-order differential<br />
equations. Do this just as you would when solving IVPs and BVPs for ODEs<br />
(see “Examples: Solving Explicit ODE Problems” on page 5-9). However, this<br />
example needs no such preparation because it already has the form <strong>of</strong> a<br />
first-order system <strong>of</strong> equations.<br />
2 Identify the lags. The delays (lags) τ 1 , …,<br />
τ k are supplied to dde23 as a<br />
vector. For the example we could use<br />
lags = [1,0.2];<br />
In coding the differential equations, τ j = lags(j).<br />
3 Code the system <strong>of</strong> first-order DDEs. Once you represent the equations as<br />
a first-order system, and specify lags, you can code the equations as a<br />
function that dde23 can use.<br />
This code represents the system in the function, ddex1de.<br />
function dydt = ddex1de(t,y,Z)<br />
ylag1 = Z(:,1);<br />
ylag2 = Z(:,2);<br />
5-54