Solving laser Rate Equation using ode 45

6 ビュー (過去 30 日間)
neda m
neda m 2019 年 7 月 9 日
コメント済み: Oriol Brasco 2019 年 7 月 9 日
Hey! I am kinda new to Matlab and I am currently doing my Project on Semiconductor lasers. I am currently trying to model the rate equations for semiconductor lasers. I have wrote a code but it shows some errors. I have been stuck on this issue for quite some time and it seems that I have done something wrong with ode45. Any type of help is greatly appreciated.
clear
clc
e=1.6e-19;
tr=1e-9;
Ntr=2e7;
g0=4.7e4;
tp=5e-12;
beta=1e-4;
eta=1;
dt=1e-12;
tend=10e-9;
T=0:dt:tend;
N(1)=0;
S(1)=0;
I=7e-3;
for t=1:length(T)-1
N(t+1)=dt*(eta*I/e-N(t)/tr-g0*(N(t)-Ntr)*S(t))+N(t);
S(t+1)=dt*(g0*(N(t)-Ntr)*S(t)-S(t)/tp+beta*N(t)/tr)+S(t);
end
[T,Y] = ODE45(@rate_equation,Y0,T,Y);
subplot 211
plot(T*tr,Y(:,1)*S)
subplot 212
plot(T*tr,Y(:,2)*N)
function dY = rate_eq(T,Y,Y0)
end

採用された回答

Oriol Brasco
Oriol Brasco 2019 年 7 月 9 日
Try using the following documentation:
Could you print where you define @rate_equation
  4 件のコメント
neda m
neda m 2019 年 7 月 9 日
I'm so sorry, I read the documentation but still don't know how to define @rate_equation in my code.
Oriol Brasco
Oriol Brasco 2019 年 7 月 9 日
Could you give some information about the function? How the function is defined? Could you print the function to be solved?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by