next up previous contents
Next: Systems of First Order Up: First Order ODEs Numerically Previous: Example   Contents

Using nsys.m

The routine nsys.m will use the Euler method to solve a 2 by 2 system. To set up the calculation, you need to edit initnsys.m. For instance, if your system of equations is

x' &=& t\,+\,x\,+\,y, \\ y' &=& x^2,

your initial conditions are $x(0)=2$, $y(0)=3$, and your desired step size is $h = 0.1$, and you want to compute up to the final time $tf=0.5$, then initnsys.m should read as follows:

t0=0; tf=0.5; x0=2; y0=3;
After you edit initnsys.m, save it, then run initnsys, followed by nsys. The graphics window will show a plot of $x$ and $y$ versus $t$, while the command window shows the computed numerical values.

Michael Renardy