Hi there.
I've written the following program.This program is part of a laser program
main program
tspan = [0 3e-9];                   
[t,y] = ode45(@rate_eq_program_1,tspan,y0);
size(t);
t=t*1e9;
param_rate_eq            
r_2=1-(abs(r_R)).^2;
plot(t,r_2)
function
function ydot = rate_eq_program_1(t,y)
 param_rate_eq              
 current1 = 18d-2;                
 
sigmaa=(2.*epsilon0.*ref_index.*ref_indexg)./(hbar.*w_s).*((1+(abs(r_R)).^2).*(1-r_R))./(conf.*V_g.*g_n.*(y(1)-N_0));
parameter
c = 3d10;                  
e = 1.6021892d-19;         
h_Planck = 6.626176d-34;   
hbar = h_Planck/(2.0*pi);  
L = 5d-4;             
w = 9d-5;               
d = 80d-8;              
V_a = 5.26d-7;              
conf = 0.5;            
conf_NC =0.3;          
V_m = V_a/conf;           
V_NC=2.4d-7;              
ref_index = 3.5;        
ref_indexg=3.5;       
V_g = c/ref_index;      
tau1 = 5d-10;          
g_n = 5d-16;           
N_0=1d18;               
N_ss=0.3d18;               
henry_i=100000;         
p=1;                     
epsilon0=8.85*10^-14;        
rho=(2*epsilon0*ref_index*c)./gamma_c.*hbar.*w_r;  
r_L=1;                            
delta_w=0.52*gamma_T;
The problem is that r_R is a function of y(2) and it is also noteworthy that the other curves obtained are correct. the value r_R remains unchanged while y(2) has changes.I expect the curve plot(t,r_2) to be as follows.(black curve)
But to my surprise, I get the following curve.
What can be the problem?
Thanks in advance for your help.
Best regards.