Commands developed especially for MA 2051 include
|dfield||Direction field of first-order equation|
|weuler||Numerical approxim ation to solution of initial-value problem via Euler method|
|wheun||Like weuler but uses Heun method|
|wrk4||Like weuler but uses fourth-order Runge-Kutta|
Each of these commands uses a so-called M-file to describe the differential equation in the form y' = f(t, y); e.g. , for the logistic equation ,P replaces y and . The correspo nding M-file is
% logistic.m - logistic equation % P' = a*P - s*P^2 function Pprime = logistic(t, P) % Note lack of ; after function line a = 0.0282; s = 0.00021; Pprime = a*P - s*P.^2;Comments are preceded by %. Note that a and s have been given specific values so that this M-file can return the numerical value of the slope Pprime at any given values of t and P.
Next: Simple Plotting
© 1996 by Will Brother. All rights Reserved. File last modified on November 21, 1996.