Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network

  Advanced Search  

Math 308, Matlab assignment 2 due February 12 in class

Summary: Math 308, Matlab assignment 2
due February 12 in class
1. In the initial value problem
= -x/y, y(0) = 5,
use Euler's method to compute approximations to y(5) with 1, 5, 50 steps. Note that you will
need to determine the step sizes yourself. Plot the results on one plot. Label the plot and the axes
The syntax is
[x, y] = eul(f, [x0, x1], y0, h)
[x, y] = eul(@function, [x0, x1], y0, h)
where f is an inline function or function an M-file function, [x0, y0] is the initial condition, x1
is the value of x where you want to compute the solution, and h is the (optional) step size. Before
running eul, you will need to create a function f(x, y) = -x/y. There are two ways to do this.
You can create an inline function, by typing
>> f = inline('-x./y','x','y');
(note the use of vectorized division ./). This is quick, but the function will be erased at the end of
the Matlab session. If you want to use it next time, create an M-file: edit opens the Matlab editor,


Source: Anshelevich, Michael - Department of Mathematics, Texas A&M University


Collections: Mathematics