
252 Programming for Chemical Engineers
3 xspan=[0:1:2];
4 init_y=[5 8];
5 k1=-0.6*init_y(1)+0.1*xspan(1);
6 k2=7-0.5*init_y(2)-0.2*init_y(1)+0.2*xspan(1);
7 [x,y]=ode45(‘odeapp’,xspan,init_y)
Line 1: Clears the Command Window.
Line 2: Clears the variables and functions from the memory.
Lines 3, 4: Initialize values of
xspan and inti_y.
Lines 5, 6: Compute
k1 and k2 (rate of reaction).
Line 7: Performs ordinary differential equations on function
odeapp and
returns the different values of
x and y.
LABORATORY EXERCISES
1) Develop a program that will solve the roots and plot the graph of any 4
th
order polynomial expression entered by the user.
2) ...