solving differential equation and plotting them

조회 수: 1 (최근 30일)
Faisal Al-Wazir
Faisal Al-Wazir 2022년 5월 28일
댓글: Torsten 2022년 5월 29일
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
Faisal Al-Wazir
Faisal Al-Wazir 2022년 5월 29일
yes it doesn't work it gives an empty plot
Torsten
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개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by