solving differential equation and plotting them

2 views (last 30 days)
greetings im trying to plot these differnatial equations but all i have is empty plots
Omega= 4;
Gamma2=4;
CapitalOmega = 2;
CapitalDelta1 = 0.8;
CapitalDelta2 = CapitalDelta1-Omega;
CapitalOmega2= 2*CapitalOmega;
CapitalGamma1=0.5+(i*CapitalDelta1);
CapitalGamma2=0.5*Gamma2+ (i*CapitalDelta2);
p=1;
syms x(t) y(t) z(t) f(t)
odex=diff(x,t)==-CapitalGamma1*x-0.5*p*sqrt(Gamma2)*y+CapitalOmega*z;
odey=diff(y,t)==-CapitalGamma2*x-0.5*p*sqrt(Gamma2)*x+CapitalOmega2*z;
odez=diff(z,t)==-CapitalOmega*x-CapitalOmega2*y;
condx= x(0) == 1;
xSol(t) = dsolve(odex,condx);
xSol=simplify(xSol)
condy= y(0) == 0;
ySol(t) = dsolve(odey,condy);
ySol=simplify(ySol)
condz= z(0) == 0;
zSol(t) = dsolve(odez,condz);
zSol=simplify(zSol)
odef=diff(f,t)== -x-y;
fSol(t) = dsolve(odef);
fSol=simplify(fSol)
fsol=subs(fSol,t,0.6)
fplot([fsol xSol ySol zSol])
  7 Comments
Torsten
Torsten on 29 May 2022
Ah, I see: xSol is complex-valued.
So you have to use
fplot(real(xSol)), fplot(imag(xSol)), fplot(abs(xSol))
to plot instead of
fplot(xSol)
If this doesn't work either, use
xSol = matlabFunction(xSol);
t = 0:0.01:3;
plot(t,abs(xSol(t))) % e.g.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!