help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: function writing in differential equations


From: Carlo de Falco
Subject: Re: function writing in differential equations
Date: Tue, 14 Oct 2008 20:27:05 +0100


On 14/ott/08, at 18:52, genehacker wrote:

xdot(1) = 0.5 * exp(-10*t) - x(4) * x(1);
xdot(2) = x(5) * 0.5 - x(6) * x(2);
xdot(3) = x(6) * x(2) - 0.5 * x(3);
x(4) = 0.5- ((0.5- 0.1)/(1 + (x(1)/5)));
x(5) = 0.5- ((0.5- 0.1)/(1 + (x(1)/5)));
x(6) = 0.1-((0.1- 0.5)/(1 + (x(1)/5)));

put in this form the system is an ODE as you can eliminate x(4:6) in terms of x(1).
You can solve the system this way:

x4 = @(x1) 0.5- ((0.5- 0.1)/(1 + (x1/5)));
x5 = @(x1) 0.5- ((0.5- 0.1)/(1 + (x1/5)));
x6 = @(x1) 0.1- ((0.1- 0.5)/(1 + (x1/5)));

xdot = @(x,t) [ 0.5 * exp(-10*t) - x4(x(1)) * x(1);
              x5(x(1)) * 0.5 - x6(x(1)) * x(2);
              x6(x(1)) * x(2) - 0.5 * x(3)];

t = linspace(0,10,100);
x = lsode (xdot, zeros(3,1), t);

plot(t,x)



c.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]