function F1
[t1,x1] = ode45(@noscillator,[0 100],[0 1]);
[t2,s1] = ode45(@(t,s) xotss(t,s,t1,x1(:,1)), [0 100], [1 0 0 0]);
for ti = 0:1:100
rho11(ti)=s1(ti,1).*s1(ti,1)'-s1(ti,3).*s1(ti,3)';
rho12(ti)=s1(ti,1).*s1(ti,2)'+s1(ti,3).*s1(ti,4)';
rho21(ti)=s1(ti,2).*s1(ti,1)'+s1(ti,4).*s1(ti,3)';
rho22(ti)=s1(ti,2).*s1(ti,2)'-s1(ti,4).*s1(ti,4)';
end
s1(:,1)
plot(t2,rho11+rho22)
function xdot=noscillator(t,x)
m=1; omega=1; beta=0.01;gamma=0.01; V=.5; w=(3.0)/(2*pi);
xdot(1) = x(2);
xdot(2) = -(omega^2)*x(1)-3*(gamma/m)*x(1)^2 - 4*(beta/m)*x(1)^3 + (V/m)*cos(w *t);
xdot=xdot';
end
function dsdt = xotss(t,s,t1,x1)
x = interp1(t1,x1,t);
dsdt = zeros(4,1);
a=1;b=0.05625;c=0.010825;d=0.5;e=0.5;f=0.01875;h=0.00625;
dsdt(1) = -1i* s(1) *(a+h*x-b) -1i* c*x* s(2);
dsdt(2) = -1i*c*x *s(1) -1i* (d-e-h*x)*s(2) +1i* f*s(3);
dsdt(3) = 1i* f*s(2) -1i*(e+h*x-d) *s(3)-1i* c*x* s(4);
dsdt(4) = -1i* c*x* s(3) -1i* (b-a-h*x)* s(4);
end
end
4 Comments
Walter Roberson (view profile)
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/488464-the-differential-equation-problem-with-variable-solution-by-using-ode45#comment_762005
abhishek singh (view profile)
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/488464-the-differential-equation-problem-with-variable-solution-by-using-ode45#comment_762007
darova (view profile)
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/488464-the-differential-equation-problem-with-variable-solution-by-using-ode45#comment_762098
abhishek singh (view profile)
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/488464-the-differential-equation-problem-with-variable-solution-by-using-ode45#comment_762111
I have solved individually the second order differential equation how to use it output as x(t) in coupled differential equation.
Sign in to comment.