there is no output, it's keep running but no output, why so?
1 view (last 30 days)
Show older comments
clc
%defining constant
ti = 0; %inital time
tf = 100E-4;% final time
tspan=[ti tf];
o = 1E6; % detuning frequency
tc = 70E-9; %photon life time in cavity
tf = 240E-6; %flouroscence lifetime
a = 0.02;
P = 1;
k = 0.11; %critical coupling strength
f = @(t,y) [ (2/tc).*((y(3)-a).*y(1) + k.*y(1).*cos(y(3) - pi/2));
(P - y(2).*(y(1)+1)).*(1/tf);
o - 2.*(1/tc).*k.*sin(y(3)-pi/2)
];
[T,Y] = ode45(f,tspan,[1;1;0]);
%plotting the graphs
plot(T,Y(:,3));
%the program is correct i think still it's happening.
0 Comments
Answers (1)
Steven Lord
on 19 Jul 2022
Let's look at the value of your integrand at the starting values.
ti = 0; %inital time
tf = 100E-4;% final time
tspan=[ti tf];
o = 1E6; % detuning frequency
tc = 70E-9; %photon life time in cavity
tf = 240E-6; %flouroscence lifetime
a = 0.02;
P = 1;
k = 0.11; %critical coupling strength
f = @(t,y) [ (2/tc).*((y(3)-a).*y(1) + k.*y(1).*cos(y(3) - pi/2));
(P - y(2).*(y(1)+1)).*(1/tf);
o - 2.*(1/tc).*k.*sin(y(3)-pi/2)
];
format longg
start = f(ti, [1; 1; 0])
So two of the three components of the solution plummet while the third takes off like a rocket. If you call ode45 with an OutputFcn you can see that one of the components does take off. If I use OutputSel to select only the second and third components to be plotted, they seem to behave somewhat reasonably, though you will have to stop it due to that first component growing so quickly. I've left the lines below commented out as they wouldn't finish execution before the MATLAB Answers timeout. You can run them in your desktop version of MATLAB.
%{
% Reasonable,
sol = ode45(f, tspan, [1; 1; 0], odeset('OutputFcn', @odeplot, 'OutputSel', [2 3]));
% Shows the first component taking off
sol = ode45(f, tspan, [1; 1; 0], odeset('OutputFcn', @odeplot, 'OutputSel', 1));
%}
I don't know what that first component of the solution is supposed to represent, but I'm guessing it's not physically realizable. You probably want to check that your implementation matches the equations you're supposed to solve. Those 1/tc and 2/tc look particularly troublesome as tc is 70e-9.
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!