## Sets of differential equations

The commands ode23 and ode45 can also be applied for sets of differential equations. For example, consider the set of differential equations

 (5.6)

The initial values and define exactly one solution.

With the commands ode23 and ode45 this type of differential equations can be tackled. To start, we write the function file deq.m' in the MATLAB Editor/Debugger', with the contents:
function xdot = deq(t,x)
xdot = [5*x(1)-2*x(2);7*x(1)-4*x(2)];

Note, that has to be a column vector. The command:

>> [t,x] = ode23('deq',[0,1],[2,8])

now calculates on the time interval [0,1] the values of and with initial conditions and . The variable becomes an array with two columns, where the first column contains the values of and the second column contains the values of . You can plot the solutions with the command:

>> plot(t,x)

Since consists of two columns, two graphs are drawn in the same figure. If you only enter the command:

>> ode23('deq',[0,1],[2,8])

the graphs of and are drawn, since by default the OutputFcn' odeplot is used. Note that you could also have written the file deq.m' in the following way:
function xdot = deq(t,x)
A = [5,-2;7,-4];
x = [x(1);x(2)];
xdot = A*x;


Esteur 2010-03-22