 ode15s - Maple Help

Matlab

 ode45
 use MATLAB(R) to solve a previously defined system, f, with ODE45
 ode15s
 use MATLAB(R) to solve a previously defined system, f, with ODE15s Calling Sequence ode45(f, Trange, IC) ode45(f, Trange, IC, tol=Tol) ode15s(f, Trange, IC) ode15s(f, Trange, IC, tol=Tol) Parameters

 f - string naming a function defined in MATLAB® Trange - range, t_initial..t_final IC - initial conditions vector; for example, [0, 0, 0] tol=Tol - optional floating-point setting for tolerance (default is .001) Description

 • The ode45 command uses MATLAB® to compute the ODE45 solution of a differential system. The ode15s command uses MATLAB® to compute the ODE15S solution of a differential system.
 • To be valid, the call must name the function (f) defined in MATLAB®, and specify both the time range (Trange) and the initial condition vector (IC).
 • The function f must either be a built-in MATLAB® function, or a function defined in the file f.m in the active MATLAB® path
 • The time range must contain both a start time (t_initial) and an end time (t_final).
 • The initial condition (IC) must have a dimension consistent with the dimension of the system defined in the function, f.
 • The tolerance option (specified using 'tol'=Tol) must be a floating-point value.  It defaults to .001 if not specified.
 • Executing the ode45 command returns two Vectors: (T, X). T is the Vector of time steps where f was evaluated, and X is a Vector of values of f, evaluated at times in T. Examples

 > $\mathrm{with}\left(\mathrm{Matlab}\right):$

Call ode45 to work on a built-in MATLAB® function.

 > $T,Y≔\mathrm{ode45}\left("vdp1",0..20,\left[2,0\right]\right)$

Call ode15s to work on a built-in MATLAB® function.

 > $T,Y≔\mathrm{ode15s}\left("vdp1000",0..30,\left[2,0\right]\right)$

Create a user-defined function, rocket, in Maple.  The file may also be predefined in the current path.

 > $\mathrm{file}≔\mathrm{open}\left("C:MATLABwork\rocket.m",\mathrm{WRITE}\right):$
 > $\mathrm{filecontents}≔"\nfunction yp = rocket\left(t,y\right)\n% time the rocket catches the target\nglobal INTERCEPT;\n% minimum distance representing intercept\nglobal DMIN;\n% ratio of pursuer speed to target speed\nk=1.3;\n% find speed and position of target\n% \left(other equations can be substituted here\right)\nif t < 10 % target changes direction after 10 seconds\n p = \left[ 10; t; 0 \right];\n vt = \left[ 0 ; 1; 0 \right];\nelse\n p = \left[ 10; 10; t-10 \right];\n vt = \left[ 0 ; 0; 1 \right];\nend\nd = sqrt\left(sum\left(\left(p-y\right).^2\right)\right); % calculate distance between P and T\nif d < DMIN % check if pursuer has caught targetN\n if t < INTERCEPT % if this is the first time, set the\n INTERCEPT = t; % interception time\n end\n k = 1; % slow down the pursuer\nend\nvp = k*sqrt\left(sum\left(vt.^2\right)\right); % set speed of pursuer\nyp = vp*\left(p-y\right)/d; % determine new position of pursuer\n":$
 > $\mathrm{writeline}\left(\mathrm{file},\mathrm{filecontents}\right):$
 > $\mathrm{close}\left(\mathrm{file}\right):$

Use the ssystem command to set the permissions on UNIX systems.

 > $\mathrm{ssystem}\left("chmod a+r rocket.m"\right):$

Open the "Matlab Link".

 > $\mathrm{with}\left(\mathrm{Matlab}\right)$

Before accessing the user-defined function, the file needs to be opened (in MATLAB®).

 > $\mathrm{evalM}\left("open\left(\text{'}C:MATLABwork\rocket.m\text{'}\right)"\right):$

Set global variables (in MATLAB®).

 > $\mathrm{setvar}\left("DMIN",0.5,'\mathrm{globalvar}'\right)$
 > $\mathrm{setvar}\left("INTERCEPT",\mathrm{\infty },'\mathrm{globalvar}'\right)$

Setup the problem.

 > $\mathrm{ti}≔0:$
 > $\mathrm{tf}≔20:$
 > $\mathrm{Yo}≔\left[0,0,0\right]:$

Solve the problem.

 > $T,Y≔\mathrm{ode45}\left("rocket",\mathrm{ti}..\mathrm{tf},\mathrm{Yo},'\mathrm{tol}'=0.0005\right):$

Plot the results.

 > $\mathrm{pursuer_plot}≔\mathrm{plots}\left[\mathrm{pointplot3d}\right]\left(\mathrm{convert}\left(Y,\mathrm{listlist}\right),\mathrm{color}=\mathrm{blue},\mathrm{symbol}=\mathrm{diamond}\right):$
 > $\mathrm{target_plot}≔\mathrm{plots}\left[\mathrm{pointplot3d}\right]\left(\left[\mathrm{seq}\left(\left[10,t,0\right],t=\mathrm{ti}..10\right),\mathrm{seq}\left(\left[10,10,t-10\right],t=10..\mathrm{tf}\right)\right],\mathrm{color}=\mathrm{red},\mathrm{symbol}=\mathrm{cross}\right):$
 > $\mathrm{plots}\left[\mathrm{display}\right]\left(\left\{\mathrm{pursuer_plot},\mathrm{target_plot}\right\},\mathrm{axes}=\mathrm{normal}\right)$