Why I cannot see any result on my graph

1 view (last 30 days)
Berk Han
Berk Han on 14 Jun 2022
Edited: Voss on 15 Jun 2022
clc
clear all
sympref('FloatingPointOutput',true)
syms X(t)
syms S1(t)
syms S2(t)
syms B1(t)
x=1
L=1
t1=0
kd=0.076
Bmax=15.658
ib=0.616
K1=171.492
Umaxg=0.730
Ksg=1.293
Ksx=4.469
Umaxx=0.615
SG=31
SGn=SG %g/l
SX=32 %g/l
B=0 %g/l
x0=0.01 %g/l
Xn=x0 %g/l
Yxsg=0.523
Yxsx=0.058
Ybsg=1.196
Ybsx=0.232
Ybxg=Ybsg/Yxsg
Ybxx=Ybsx/Yxsx
Usg=(Umaxg*SG)/((Ksg+SG)*((1+SX)/Ksx))
Usx=(Umaxx*SX)/((Ksx+SX)*((1+SG)/Ksg))
Ug=(Usg+Usx)*(K1/(K1+SG+SX))*(1-(B/Bmax))^(ib)
Unet=Ug-kd
ode = diff(X,t)==Unet*X;
cond=X(t1)==Xn;
XSol(t)=dsolve(ode,cond)
ode = diff(S1,t)== -Usg*((1/Yxsg)+(1/Ybsg))*XSol;
cond= S1(t1)==SGn;
SGsol(t)=dsolve(ode,cond)
ode = diff(S2,t)== -Usx*((1/Yxsx)+(1/Ybsx))*XSol;
cond= S2(t1)==SGn;
SXsol(t)=dsolve(ode,cond)
ode = diff(B1,t)== (Usg*Ybxg+Usx*Ybxx)*XSol;
cond= B1(t1)==B
Bsol(t)=dsolve(ode,cond)
for i=0:10:300
XSol(i);
SGsol(i) ;
SXsol(i);
Bsol(i);
end
plot(i,SXsol(i))

Accepted Answer

Voss
Voss on 14 Jun 2022
Instead of this:
plot(i,SXsol(i))
try this:
fplot(SXsol,[0 300])
or this:
t_plot = 0:10:300;
plot(t_plot,SXsol(t_plot))
  2 Comments
Berk Han
Berk Han on 14 Jun 2022
Thank you!
fplot(SXsol,[0 300]) is working in my code.
Voss
Voss on 14 Jun 2022
Edited: Voss on 15 Jun 2022
You're welcome!

Sign in to comment.

More Answers (1)

Cris LaPierre
Cris LaPierre on 14 Jun 2022
By default, MATLAB plots using a solid line style with no marker. When you plot a single point like your code is doing, this results in your point not being visible.
If you truly want to plot the ith point, then add a marker style.
plot(i,SXsol(i),'o')
If you instead want to plot all your data, remove i.
plot(SXsol)
  2 Comments
Berk Han
Berk Han on 14 Jun 2022
Thanks but plot(SXsol) didnt work.
Cris LaPierre
Cris LaPierre on 14 Jun 2022
Edited: Cris LaPierre on 14 Jun 2022
I overlooked that SXsol was a symfun. Use one of the solutions described by Voss.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!