Trying to graph two differential equations on same plot
Show older comments
T1=50+273.15; %%k
T2=127+273.15; %%k
Fao=2.5; %%mol/min
P=10; %%atm
k1=10^-4; %%min^-1
R=8.314; %j/k*mol
R1=8.206*10^-5*1000; %%atm*dm^3/K*mol
E=85*1000; %%j/mol
k2=k1*exp(E/R*(1/T1-1/T2)); %%min^-1
cao=P/(T2*R1); %%mol/dm^3
ep=2+1-1;
xf=.90;
alpha=.001; %%dm^3
volcstr=(Fao*xf)*(1+ep*xf)/(k2*cao*(1-xf)); %%dm^3
fun=@(x) Fao/(cao*k2)*(1+ep*x)./(1-x);
volpfr=integral(fun,0,xf); %%dm^3
[x,y]=ode45(@(x,y) jallohwfun7(alpha,ep,xf,y,cao,k2,Fao),[0 500],[0 1]);
plot(x,y(:,1),'r','LineWidth',1);
hold on;
plot(x,y(:,2),'k','LineWidth',1);
legend('Pressure', 'Conversion');
xlabel('Volume [dm^3]');
ylabel('Pressure [atm] & Conversion');
title('Pressure and Conversion vs Volume ');
function dydt=jallohwfun7(alpha,ep,xf,y,cao,k2,Fao)
dydt=zeros(2,1);
dydt(1)=-alpha*(1+ep*xf)/2*y(1);
dydt(2)=k2*cao/Fao*(1-y(2))/(1+ep*y(2));
end
I want to graph two differential equations on same graph however i keep getting a straight line for both equations, which is incorrect. 

Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!