我写了一个有关光通过很多光学器件的程序,其实主要内容就是一个随频率变化的光通过几个光学元件,最后通过积分计算相位误差。以下是程序:
%function ff=ff(f)
%在一定波长范围内第i个波长为λ_i, 对应的光功率为P (λ_i )
%========初始参数设定
clear all
clc
segmai=40e-009;
F1=230e+009;
syms f
p=1/(sqrt(2*pi)*segmai)*exp(-(f-F1)^2/(2*segmai^2));
r1=0.4;
c=3e+008;
Ln=0.7;
%==================%
theta_7=pi/180;theta_3=pi/90;
theta_6=pi/180;theta_2=pi/90;
theta_1=pi/180;theta_4=pi/90;
theta_5=pi/90;
A_lamda=sqrt(p);
Es_lamda=[sqrt((1+p)/2),sqrt((1-p)/2)].'*A_lamda;
R_theta_1=[cos(theta_1),sin(theta_1);-sin(theta_1),cos(theta_1)];
R_theta_2=[cos(theta_2),sin(theta_2);-sin(theta_2),cos(theta_2)];
R_theta_3=[cos(theta_3),sin(theta_3);-sin(theta_3),cos(theta_3)];
R_theta_4=[cos(theta_4),sin(theta_4);-sin(theta_4),cos(theta_4)];
R_theta_5=[cos(theta_5),sin(theta_5);-sin(theta_5),cos(theta_5)];
R_theta_6=[cos(theta_6),sin(theta_6);-sin(theta_6),cos(theta_6)];
R_theta_7=[cos(theta_7),sin(theta_7);-sin(theta_7),cos(theta_7)];
%保偏耦合器的琼斯矩阵. 设保偏耦合器总长为Lc,分束比为k1;损耗为r1
k1=0.49;
Nxy=1.6e-006;
Lc=1.5;
tc=Lc*(Nxy)/c;
a1=exp(-j*2*pi*f*tc);
A=[1 0;0 a1 ];
Kt1=(10^(-r1/20))*sqrt(1-k1)*A;
%设Y波导输入、输出尾纤的长度分别是ln ( n = 67, 23, 54)
tn=Ln*(Nxy)/c;
a2=exp(-j*2*pi*f*tn);
D_ln=[1 0;0 a2];
L2=0.75/0.8;
t_2=L2*(Nxy)/c;
a22=exp(-j*2*pi*f*t_2);
D_l2=[1 0;0 a22];
L1=0.7;
t_1=L2*(Nxy)/c;
a11=exp(-j*2*pi*f*t_1);
D_l1=[1 0;0 a11];
%Y波导芯片的琼斯矩阵. 设点7和点2与点7和点5之间波导长度分别是lu 和ld
k2=0.51;
Lu=0.025;
Ld=0.027;
r2=2.8;%db
p1=(10^(-r2/20))*sqrt(1-k2);
p2=(10^(-r2/20))*sqrt(1-k2);
tu=Lu*(Nxy)/c;
td=Ld*(Nxy)/c;
a3=p1*exp(-j*2*pi*f*td);
a4=p2*exp(-j*2*pi*f*tu);
D_ld=-j*[p1 0;0 a3];
D_lu=-j*[p2 0;0 a4];
%光纤环的琼斯矩阵. 设光纤环的损耗与串音分别为Rf,gama_ct
Vct=17;
rf=1.06;
Lf=1500;
Lr=80.4*10^(-6);
tf=Lf*(Nxy)/c;
a5=exp(-j*2*pi*f*tf);
h=(-1/(2*Lf))*log((10^Vct/10)-1/((10^Vct/10)+1));
S_12=(sqrt(h*Lr))*(1+a5);
S_21=-(sqrt(h*Lr))*(1+a5);
D_lf=10^(-rf/20)*[1 S_12;S_21 a5];
%进入Y波导芯片之前的光电场为E_in
E_in=R_theta_7*D_ln*R_theta_6*Kt1*R_theta_1*Es_lamda;
G_cw=D_ld*R_theta_5*D_l2*R_theta_4*D_lf*R_theta_3*D_l1*R_theta_2*D_lu;
G_ccw=G_cw.';
e=0.01;
u=0;
E_cw_Fi=G_cw*exp(j*u)*E_in;
E_cw=D_ld*R_theta_5*D_l2*R_theta_4*D_lf*R_theta_3*D_l1*R_theta_2*D_lu*E_in;
E_ccw_Fi=G_ccw*exp(-j*u)*E_in;
angle=atan((E_ccw_Fi)'*E_cw_Fi);
derta_ampFi=e*imag(1*G_cw(2,1)*G_cw(1,1)*E_in(2,1)'*E_in(1,1)+G_cw(1,1)*1*G_cw(1,2)*E_in(1,1)'*E_in(2,1))/(((G_cw(1,1).*G_cw(1,1))*(E_in(1,1).*E_in(1,1))));
derta_intenFi=(e^2)*imag(1*G_cw(1,2)'*1*G_cw(2,1)*((E_in(1,1).*E_in(1,1))-(E_in(2,1).*E_in(2,1))))/(((G_cw(1,1).*G_cw(1,1))*(E_in(1,1).*E_in(1,1))));
derta_eFi=derta_ampFi+derta_intenFi;
h=G_cw(1,1)*1/e*G_cw(1,2)*E_in(1,1)'*E_in(2,1);
k=(G_cw(1,1).*G_cw(1,1))*(E_in(1,1).*E_in(1,1));
l=G_cw(1,1)*1/e*G_cw(2,1)'*E_in(1,1)'*E_in(2,1);
m=1/e*G_cw(1,2)*1/e*G_cw(2,1)*(E_in(1,1).*E_in(1,1)-E_in(2,1).*E_in(2,1));
aaa=int(h,220e+009,240e+009);
bbb=int(k,220e+009,240e+009);
ccc=int(l,220e+009,240e+009);
ddd=int(m,220e+009,240e+009);
derta_ampFitol=e*imag(aaa)/bbb+e*imag(ccc)/bbb;
derta_intentolFi=(e^2)*imag(ddd)/bbb;
derta_etolFi=derta_ampFitol+derta_intentolFi;
这是错误提示??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Error in ==> sym.maple at 94
result = reshape(result,size(varargin{3}));
Error in ==> sym.int at 51
r = reshape(maple('map','int',f(:),[x.s '=(' a.s ')..(' b.s ')']),size(f));
Error in ==> likai2 at 95
ccc=int(l,220e+009,240e+009);
这是我的毕设内容,很关键的。求求各位大虾帮忙了!!!!
[本帖最后由 mooni 于 2009-5-22 13:00 编辑]