You are on page 1of 2

Solving two differential equations

1. Create a function defining your differential equations:

Function file:

% "LEP_4_6"

% m-file to solve example 4-6

% x(1)=X

% x(2)=y

% xdot(1)=dX/dW, xdot(2)=dy/dW

function xdot=LEP_4_6(w,x)

global kprime alpha fa0 eps

kprime=26.65;

eps=-0.15;

alpha=0.0366;

fa0=489.6;

xdot(1,:)=(kprime*((1-x(1))/(1+eps*x(1)))*x(2))/fa0;

xdot(2,:)=-alpha*(1+eps*x(1))/(2*x(2));

2. Then creating a script file and call the ODE function like ODE45

m-file
% Initial Conditions for X and y
ic=[0;1];

% Define the range of catalyst weight


wspan=[0 20];

% call the ode45 function

[w,x]=ode45('LEP_4_6',wspan,ic);

% to obtain the volumetric flow rate profile


f=(1+eps.*x(:,1))./x(:,2);

% Plot the output

plot(w,x,w,f);

title('Example 4-6');

xlabel('W (kg)');

ylabel('X,y,f');

grid on

legend('X','y','f')

You might also like