I couldn't understand why this program is not working, is my all variable algorithm is correct?
Afficher commentaires plus anciens
clc
ti = 0;
tf = 10E-4;
tspan=[ti tf];
y0=[9;9;1;1;0].*10E-2;
I =0:0.1 :10 ;
Vf = zeros(length(I),1) ;
for i = 1:length(I)
[T,Y]= ode45(@(t,y) rate_eq(y,I(i)),tspan,y0);
Vf(i) = (2.*(((mean(Y(:,1).*Y(:,2).*cos(Y(:,5)))).^2 + (mean(Y(:,1).*Y(:,2).*sin(Y(:,5)))).^2).^0.5))/(mean(Y(:,1).^2)+mean(Y(:,2).^2));
end
disp(Vf)
function dy = rate_eq(y,I)
dy = zeros(5,1);
o = 2E5; %detuning frequency
tc = 30E-9; %photon cavity lifetime
tf = 230E-6; %fluorescence lifetime
a1 = 0.1; %roundtrip loass
a2 = 0.1;
P1 = 0.2; %pumpstrength
P2 = 0.2;
kc = 3E-3; %critical coupling strength
s = 0.17;
k = s.*kc;
%amplitude equation
dy(1) = ((y(3) - a1) * y(1) + k * y(2) * cos(y(5))) ./ tc;
dy(2) = ((y(4) - a2) * y(2) + k * y(1) * cos(y(5))) ./ tc;
%gain medium strength
dy(3) = (P1 - y(3) * (((abs(y(1)))^2 .*I) + 1)) / tf;
dy(4) = (P2 - y(4) * (((abs(y(2)))^2 .*I) + 1)) / tf;
%phase differential equation
dy(5) = o - (k / tc) * (((y(1) ./ y(2)) + (y(2) ./ y(1))) * sin(y(5)));
end
3 commentaires
KSSV
le 12 Juil 2022
Whjat do you mean by not working? It throws any error? Be specific.
SAHIL SAHOO
le 12 Juil 2022
SAHIL SAHOO
le 12 Juil 2022
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!