Trying to graph two differential equations on same plot

4 Ansichten (letzte 30 Tage)
Rodrigo Blas
Rodrigo Blas am 19 Mär. 2020
Kommentiert: Rodrigo Blas am 22 Mär. 2020
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.

Akzeptierte Antwort

David Goodmanson
David Goodmanson am 19 Mär. 2020
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.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by