solving differential equation and plotting them
古いコメントを表示
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 件のコメント
Torsten
2022 年 5 月 28 日
You mustn't solve the differential equations one after the other, but all in one.
Faisal Al-Wazir
2022 年 5 月 28 日
Torsten
2022 年 5 月 29 日
And what is the problem ? Matlab returned the solutions for x, y and z.
Faisal Al-Wazir
2022 年 5 月 29 日
fplot(xSol)
does not work ?
Faisal Al-Wazir
2022 年 5 月 29 日
Torsten
2022 年 5 月 29 日
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.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!