求助:我在传输随机NRZ信号进laser rate equation老出错,高人帮我看看吧(code见内)
小弟做毕业设计第一步,要把一个nrz 信号放到激光rate equation里去,老是出错,下面我详细讲一下,希望各位大哥大姐帮我解答一下,困扰了好几天了。
我先用matlab模拟了一个rate equation 电流是一个恒定值,成功了,code如下:
function [dy] = rate_equation2(t,y)
dy = zeros(2,1);
tau_s = 3e-9; % carriers lifetime
tau_p = 1e-12; % photons lifetime
A = 1e-12; % linear gain costant
N0 = 1e24; % trasparency carries density
V = 3.75e-14; % modal volume
gamma = 1e-5; % gain compression factor
q = 1.6e-19; % electron charge
I0 = N0*q*V/tau_s; % trasparency current
tau_norm = tau_s/tau_p;
eta = A*tau_p*N0; % efficiency
I = 3*I0;
dy(1)= I/I0 -y(2)*(y(1) - 1) -y(1);
dy(2) = tau_norm*(y(2)*(eta*(y(1) - 1) -1) + gamma*eta*y(1));
end
然后把这个function画出来:
clc
clear all
close all
tau_s = 3e-9;
N0 = 1e24;
A =1e-12;
P0 = 1/(A*tau_s);
TSPAN = [0 10];
Y0 =[0 0];
[T,Y] = ODE45(@rate_equation1,TSPAN,Y0);
subplot(2,1,1)
plot(T*tau_s ,Y(:,1)*N0)
title('plot of photon densities')
subplot(2,1,2)
plot(T*tau_s ,Y(:,2)*P0)
title('plot of carrier densities')
这都成功了不过当我想把一个nrz data 当成电流放到公式里面看看photon变化就一直错误。下面是function2 code:
function [dy] = rate_equation2(t,y)
dy = zeros(2,1);
%generate NRZ siganl ---------------------------------------------------
T1=1; % symbol duration
nb=100; % number of transmiting bits
delta_T=T1/100;
% generate source data
data=randn(1,nb)>0.5;
datanrz=data.*2+0.5; % translate source data into NRZ code
data1=zeros(1,nb/delta_T);
for q=1:nb
data1((q-1)/delta_T+1:q/delta_T)=datanrz(q);
end % transmiting signal
I = data1; % pumping data
%------------------------------------------------------------------------
tau_s = 3e-9; % carriers lifetime
tau_p = 1e-12; % photons lifetime
A = 1e-12; % linear gain costant
N0 = 1e24; % trasparency carries density
V = 3.75e-14; % modal volume
gamma = 1e-5; % gain compression factor
q = 1.6e-19; % electron charge
I0 = N0*q*V/tau_s; % trasparency current
tau_norm = tau_s/tau_p;
eta = A*tau_p*N0; % efficiency
% I = 3*I0;
dy(1)= I/I0 -y(2)*(y(1) - 1) -y(1);
dy(2) = tau_norm*(y(2)*(eta*(y(1) - 1) -1) + gamma*eta*y(1));
end
错误显示:
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
我就把一电流是恒定值改成了一个nrz的变化值,就是错误,我试了很久都没找到错误,希望好心人能帮助我,另外抱歉有些用词不太准确。
|