I couldn't understand why this program is not working, is my all variable algorithm is correct?
이전 댓글 표시
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
KSSV
2022년 7월 12일
Whjat do you mean by not working? It throws any error? Be specific.
SAHIL SAHOO
2022년 7월 12일
SAHIL SAHOO
2022년 7월 12일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!