15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Initial Value Problems for ODEs and DAEs<br />

(t,y) for µ = MU. The use <strong>of</strong> an analytic Jacobian can improve the reliability<br />

and efficiency <strong>of</strong> integration.<br />

To run this example, click on the example name, or type vdpode at the<br />

command line. From the command line, you can specify a value <strong>of</strong> µ as an<br />

argument to vdpode. The default is µ = 1000.<br />

function vdpode(MU)<br />

%VDPODE Parameterizable van der Pol equation (stiff for large MU)<br />

if nargin < 1<br />

MU = 1000; % default<br />

end<br />

tspan = [0; max(20,3*MU)];<br />

y0 = [2; 0];<br />

options = odeset('Jacobian',@J);<br />

% Several periods<br />

[t,y] = ode15s(@f,tspan,y0,options);<br />

plot(t,y(:,1));<br />

title(['Solution <strong>of</strong> van der Pol Equation, \mu = ' num2str(MU)]);<br />

xlabel('time t');<br />

ylabel('solution y_1');<br />

axis([tspan(1) tspan(end) -2.5 2.5]);<br />

---------------------------------------------------------------<br />

function dydt = f(t,y)<br />

dydt = [<br />

y(2)<br />

MU*(1-y(1)^2)*y(2)-y(1) ];<br />

end % End nested function f<br />

---------------------------------------------------------------<br />

function dfdy = J(t,y)<br />

dfdy = [ 0 1<br />

-2*MU*y(1)*y(2)-1 MU*(1-y(1)^2) ];<br />

end % End nested function J<br />

end<br />

5-21

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

Saved successfully!

Ooh no, something went wrong!