Hi everyone, i have a problem with the plot of the next function:
function xd=lic(t,x)
global YH YA fp iXB iXP miuH bH KS KOH KNO miuA bA KOA KNH niug ka kh KX niuh
xd(1)=(miuH*(x(3)/(KS+x(3)))*(((x(10)/(KOH+x(10)))+niug*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))-bH))*x(1);
xd(2)=(miuA*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))-bA)*x(2);
xd(3)=((-miuH/YH)*(x(3)/(KS+x(3)))*((x(10)/(KOH+x(10)))+niug*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))+kh*((x(4)/x(1))/(KX+(x(4)/x(1))))*((x(10)/(KOH+x(10)))+niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))))*x(1);
xd(4)=(1-fp)*(bH*x(1)+bA*x(2))-kh*(x(4)/x(1))/(KX+x(4)/x(1))*((x(10)/(KOH+x(10)))+niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))*x(1);
xd(5)=fp*(bH*x(1)+bA*x(2));
xd(6)=(iXB-fp*iXP)*(bH*x(1)+bA*x(2))-kh*(x(6)/x(1))/(KX+(x(4)/x(1)))*((x(10)/(KOH+x(10)))+niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))*x(1));
xd(7)=(-ka*x(7)+kh*((x(6)/x(1))/(KX+x(4)/x(1)))*((x(9)/(KOH/x(9)))+ niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))))*x(1);
xd(8)=(-iXB*miuH*(x(3)/(KS+x(3)))*(x(10)/(KOH+x(10))+niug*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))+ka*x(7))*x(1)-miuA*(iXB+(1/YA))*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))*x(2);
xd(9)=-miuH*niug*(1-YH)/(2.86*YH)*(x(3)/(KS+x(3)))*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))*x(1)+(miuA/YA)*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))*x(2);
xd(10)=-miuH*((1-YH)/YH)*(x(3)/(KS+x(3)))*(x(10)/(KOH+x(10)))*x(1)-miuA*((4.57-YA)/YA)*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))*x(2);
xd=xd';
end
script:
global YH YA fp iXB iXP miuH bH KS KOH KNO miuA bA KOA KNH niug ka kh KX niuh
YH=0.67;
YA=0.24;
fp=0.08;
iXB=0.086;
iXP=0.06;
miuH=6.0;
bH=0.62;
KS=20;
KOH=0.20;
KNO=0.50;
miuA=0.80;
bA=0.20;
KOA=0.4;
KNH=1.0;
niug=0.8;
ka=0.08;
kh=3.0;
KX=0.03;
niuh=0.4;
x0=[0 0 0 0 0 0 0 0 0 0];
t0=0;
tf=10;
[t,x]=ode45(@lic, [t0 tf], x0);
figure(1)
subplot(511)
plot(t,x(:,1),'r')
title('1 ')
subplot(512)
plot(t,x(:,2),'b')
title('2')
subplot(513)
plot(t,x(:,3),'y')
title('3')
grid
subplot(514)
plot(t,x(:,4),'k')
title('4')
grid
subplot(515)
plot(t,x(:,5),'g')
title('5')
grid
figure(2)
subplot(511)
plot(t,x(:,6),'r')
title('6 ')
grid
subplot(512)
plot(t,x(:,7),'b')
title('7')
grid
subplot(513)
plot(t,x(:,8),'y')
title('8')
grid
subplot(514)
plot(t,x(:,9),'k')
title('9')
grid
subplot(515)
plot(t,x(:,10),'g')
title('10')
I don't understand why it is displayed empty. Thanks

 Risposta accettata

Star Strider
Star Strider il 25 Mar 2021
It is best to not use global variables.
The ‘lic’ funciton should be:
function xd=lic(t,x, YH, YA, fp, iXB, iXP, miuH, bH, KS, KOH, KNO, miuA, bA, KOA, KNH, niug, ka, kh, KX, niuh)
xd(1)=(miuH*(x(3)/(KS+x(3)))*(((x(10)/(KOH+x(10)))+niug*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))-bH))*x(1);
xd(2)=(miuA*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))-bA)*x(2);
xd(3)=((-miuH/YH)*(x(3)/(KS+x(3)))*((x(10)/(KOH+x(10)))+niug*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))+kh*((x(4)/x(1))/(KX+(x(4)/x(1))))*((x(10)/(KOH+x(10)))+niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))))*x(1);
xd(4)=(1-fp)*(bH*x(1)+bA*x(2))-kh*(x(4)/x(1))/(KX+x(4)/x(1))*((x(10)/(KOH+x(10)))+niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))*x(1);
xd(5)=fp*(bH*x(1)+bA*x(2));
xd(6)=(iXB-fp*iXP)*(bH*x(1)+bA*x(2))-kh*(x(6)/x(1))/(KX+(x(4)/x(1)))*((x(10)/(KOH+x(10)))+niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))*x(1));
xd(7)=(-ka*x(7)+kh*((x(6)/x(1))/(KX+x(4)/x(1)))*((x(9)/(KOH/x(9)))+ niuh*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))))*x(1);
xd(8)=(-iXB*miuH*(x(3)/(KS+x(3)))*(x(10)/(KOH+x(10))+niug*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9))))+ka*x(7))*x(1)-miuA*(iXB+(1/YA))*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))*x(2);
xd(9)=-miuH*niug*(1-YH)/(2.86*YH)*(x(3)/(KS+x(3)))*(KOH/(KOH+x(10)))*(x(9)/(KNO+x(9)))*x(1)+(miuA/YA)*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))*x(2);
xd(10)=-miuH*((1-YH)/YH)*(x(3)/(KS+x(3)))*(x(10)/(KOH+x(10)))*x(1)-miuA*((4.57-YA)/YA)*(x(8)/(KNH+x(8)))*(x(10)/(KOA+x(10)))*x(2);
xd=xd';
end
and the ode45 call to it:
[t,x]=ode45(@(t,x)lic(t,x, YH, YA, fp, iXB, iXP, miuH, bH, KS, KOH, KNO, miuA, bA, KOA, KNH, niug, ka, kh, KX, niuh), [t0 tf], x0);
The initial conditions are identically 0, so all the results are 0 as well. The plots are a horizontal line at 0 for every one as the result. With non-zero initial conditions, for example:
x0=[0 0 0 0 0 0 0 0 0 0]+0.1;
the plots are no longer 0 and is likely resemble the desired result.

2 Commenti

Mihaela Lazar
Mihaela Lazar il 25 Mar 2021
Thank you very much!
Star Strider
Star Strider il 25 Mar 2021
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by