Prof. Alexandre Bayen
Introduction to Programming for Engineers
Lab 11: Ordinary Differential Equations
Date Assigned: 5:00pm, Friday – April 22.
Date Due: 5:00pm, Friday – April 29.
The following help file for ode45 will be helpful for you during this lab.
[TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL]
integrates the system of differential equations y' = f(t,y) from
function handle. For a scalar T and a vector Y, ODEFUN(T,Y) must
return a column vector corresponding to f(t,y). Each row in the
solution array YOUT corresponds to a time returned in the column
..,TFINAL (all increasing or all decreasing), use TSPAN =
[T0 T1 .
The logistics equation is a simple differential equation model that can be used to relate the change
in population dP/dt to the current population, P, given a growth rate, r, and a carrying capacity, K. The logistics
equation can be expressed by:
Write a function with header
[dP] = myLogisticsEq(t, P, r, K)
that represents the Logistics equation.
Note that this format allows
to be used as an input argument to
. You may assume that
are all scalars, and
is the value dP/dt given
Note that the input
, is obligatory if
is to be used as an input argument to
, even though it is part
of the differential equation.
: The logistics equation has an analytic solution defined by:
is the initial population. As an exercise, you should verify that this equation is a solution to the