## Problems with ODE system using ode45

### Dennis (view profile)

on 13 Nov 2019 at 13:14
Latest activity Edited by Dennis

### Dennis (view profile)

on 13 Nov 2019 at 13:36
I would like to solve (and then plot the solution of) the Ordinary Differential Equation system
with initial conditions
.
Note that one needs to choose in order to make sense of the equations for . My first attempt is to choose them constantly such that
I tried to implement this system in Matlab.
First, I wrote the function myODE for the right hand side of the system; then I tried to used ode45. The code can be seen below.
Unfortunately, there seems to be a mistake because the plot only shows the initial conditions and, moreover, the time range is from -1 to 1 (see the following image) which is not what I would like to plot.
Where is the mistake in my code?
function dxdt = myODE(t,x,lambda,mu,y0,y4) %
% y0 = leftmost outer neighbour (constant)
% y4 = rightmost outer neighbour (constant)
dxdt = [exp(lambda*(x(2)-x(1)))+exp(mu*(x(1)-y0)); ...
exp(lambda*(x(3)-x(2)))+exp(mu*(x(2)-x(1))); ...
exp(lambda*(y4-x(3))+exp(x(3)-x(2)))];
%%%%% Next: Try to use ode45:
%%% arbitrary choice of lambda, mu, y0 and y4 just for testing the code
lambda=1;
mu=1;
y0=0;
y4=50;
% initial conditions: y_1=5, y_2=10, y_3=15
% consider 100 time steps
[t,X] = ode45(@(t,x) myODE(t,x,lambda,mu,y0,y4),[0 100], [5; 10; 15]);
% plot x_1=X(1), x(2)=X(2), x(3)=X(3) against t
plot(t,X(:,1),'-o',t,X(:,2),'-o',t,X(:,3),'-o')
xlabel('Time t');
ylabel('Solution x');
legend('x_1','x_2','x_3')