MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of MATLAB Mathematics - SERC - Index of

serc.iisc.ernet.in
from serc.iisc.ernet.in More from this publisher
15.11.2014 Views

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

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

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!