there is no output, it's keep running but no output, why so?

조회 수: 3 (최근 30일)
SAHIL SAHOO
SAHIL SAHOO 2022년 7월 19일
답변: Steven Lord 2022년 7월 19일
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.

답변 (1개)

Steven Lord
Steven Lord 2022년 7월 19일
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])
start = 3×1
1.0e+00 * -571428.571428571 -4166.66666666667 4142857.14285714
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.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by