To solve the logistic equation numerically in MATLAB we must
begin by writing a `function` which represents the right-hand-side of the
logistic equation, which the MATLAB program will then use in the numerical
solution. Open an editor window in MATLAB and type in the following function:

function ydot=logistic(t,y) % right hand side of logistic equation for a matlab numerical % solution. % r is the intrinsic growth rate % K is the carrying capacity r=.5; K=10; ydot=r*y*(1-y/K);Now, save this as

tspan=[0 20]; y0=1; [t,y] = ode45('logistic', tspan, y0);The vector

plot(t,y), xlabel('Time'), ylabel('Population Density')

EXERCISE 4: Find solutions to the logistic equation for several different initial
conditions and plot them simultaneously; on your composite plot also plot the
carrying capacity. You may want to just give solutions for different initial
conditions different names (e.g. y1, y2, y3, ...)
and/or use the hold on command. |
||

EXERCISE 5: Use MATLAB to investigate the effect of constant `harvesting' of the
population, that is, to see what happens when we subtract a constant amount,
, of
the population per time. This changes the logistic equation to
Test several different initial conditions. Is it now guaranteed that any small initial population will grow to carrying capacity? |
||

2002-02-15