15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Initial Value Problems for ODEs and DAEs<br />

function yp = odefcn(x,y)<br />

yp = ((1 - x)*y - y^2)/epsilon;<br />

end<br />

end % kneeode<br />

The derivative function is defined within nested function odefcn. The value <strong>of</strong><br />

epsilon used in odefcn is obtained from the outer function:<br />

function yp = odefcn(x,y)<br />

yp = ((1 - x)*y - y^2)/epsilon;<br />

end<br />

The demo solves the problem using the ode15s function, first with the default<br />

options, and then by imposing a nonnegativity constraint. To run the demo,<br />

type kneeode at the <strong>MATLAB</strong> command prompt.<br />

Here is the output plot. The plot confirms correct solution behavior after<br />

imposing constraints.<br />

5-41

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

Saved successfully!

Ooh no, something went wrong!