Trying to graph two differential equations on same plot

조회 수: 4 (최근 30일)
Rodrigo Blas
Rodrigo Blas 2020년 3월 19일
댓글: Rodrigo Blas 2020년 3월 22일
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.

채택된 답변

David Goodmanson
David Goodmanson 2020년 3월 19일
Hi Rodrigo,
you have the following:
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
with initial conditions y(1) = 0, y(2) = 1. Plugging those in gives dy/dt(1) = 0, dy/dt(2) = 0 so the system never gets off the schneid. It just stays in the initial state.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by