Sets of first order differential equations

You can also enter a set of differential equations. In this case you need to indicate what the output variables are. For example,
>> [x1,x2] = dsolve('Dx1=5*x1-2*x2','Dx2=7*x1-4*x2')

x1 =
x2 =
gives the general solution of equation (5.2). Note that this general solution depends on arbitrary constants $ C_1$ and $ C_2$ . If you want to specify initial conditions, you can do this in the following way:
>> [x1,x2] = dsolve('Dx1=5*x1-2*x2','Dx2=7*x1-4*x2','x1(0)=0','x2(0)=5')

x1 =
x2 =
If you want to plot the functions $ x_1$ and $ x_2$ , you can do this with the commands ezplot(x1) and ezplot(x2). If you want to plot the state [$ x_1$ ,$ x_2$ ] in the phase plane, you first need to calculate $ x_1$ and $ x_2$ for a range of values of $ t$ . For example:
>> t = [0:0.1:1];
>> X = subs(x1,t);
>> Y = subs(x2,t);
>> plot(X,Y)

Previous      Next      Up      Contents

Esteur 2010-03-22