solving differential equation and plotting them
Afficher commentaires plus anciens
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 commentaires
Torsten
le 28 Mai 2022
You mustn't solve the differential equations one after the other, but all in one.
Faisal Al-Wazir
le 28 Mai 2022
Torsten
le 29 Mai 2022
And what is the problem ? Matlab returned the solutions for x, y and z.
Faisal Al-Wazir
le 29 Mai 2022
fplot(xSol)
does not work ?
Faisal Al-Wazir
le 29 Mai 2022
Torsten
le 29 Mai 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.
Réponses (0)
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!