matlab中的问题此程序没错na=2.10;nb=1.46;n1=1;n2=1;for d=400:1600;c3=0;c1=asin(n1*sin(c3)/na);c2=asin(na*sin(c1)/nb);c4=asin(nb*sin(c2)/n2);d1=1064;a=d1/(4*na);b=d1/(4*nb);Ba=2*pi*na*a*cos(c1)/d;Bb=2*pi*nb*b*cos(c2)/d;f=4*pi*1e-7;e=1e-9/(36*p
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 23:58:21
matlab中的问题此程序没错na=2.10;nb=1.46;n1=1;n2=1;for d=400:1600;c3=0;c1=asin(n1*sin(c3)/na);c2=asin(na*sin(c1)/nb);c4=asin(nb*sin(c2)/n2);d1=1064;a=d1/(4*na);b=d1/(4*nb);Ba=2*pi*na*a*cos(c1)/d;Bb=2*pi*nb*b*cos(c2)/d;f=4*pi*1e-7;e=1e-9/(36*p
matlab中的问题
此程序没错
na=2.10;nb=1.46;n1=1;n2=1;
for d=400:1600;
c3=0;c1=asin(n1*sin(c3)/na);c2=asin(na*sin(c1)/nb);c4=asin(nb*sin(c2)/n2);
d1=1064;
a=d1/(4*na);b=d1/(4*nb);
Ba=2*pi*na*a*cos(c1)/d;
Bb=2*pi*nb*b*cos(c2)/d;
f=4*pi*1e-7;
e=1e-9/(36*pi);
m=sqrt(e/f);
za=m*cos(c1)*na;zb=m*cos(c2)*nb;z1=f*cos(c3)*n1;z2=f*cos(c4)*n2;
p1=cos(Bb);p2=-i*sin(Bb)/zb;p3=-i*zb*sin(Bb);p4=cos(Bb);
P=[p1 p2;p3 p4];
q1=cos(Ba);q2=-i*sin(Ba)/za;q3=-i*za*sin(Ba);q4=cos(Ba);
Q=[q1 q2;q3 q4];
O=Q*P;O1=O^27;
O11=O1(1,1);O12=O1(1,2);O13=O1(2,1);O14=O1(2,2);
z1=sqrt(e/f)*n1*cos(c3);z2=sqrt(e/f)*n2*cos(c4);
t=2*z1/(z1*(O11+z2*O12)+O13+z2*O14);
r=(z1*(O11+z2*O12)-O13-z2*O14)/(z1*(O11+z2*O12)+O13+z2*O14);
t1=abs(t);
r1=abs(r);
s=d-399;
k(1,s)=t1;
end
d=400:1600;
plot(d,k)
为什么我把d的范围和d1的值改了一下又不能运行呢?错误:On line 32 ==> plot(d,k),修改的地方以换行表示
na=1.926;nb=3.23;n1=1;n2=1;nc=1.585;nd=3.55;
for d=1100:1800;
c3=0;c1=asin(n1*sin(c3)/na);c2=asin(na*sin(c1)/nb);c4=asin(nb*sin(c2)/n2);
cc=asin(nc*sin(c3)/na);cd=asin(nd*sin(c3)/na);
d1=1550;
a=d1/(4*na);b=d1/(4*nb);c=d1/(4*nc);dd=d1/(4*nd);
Ba=2*pi*na*a*cos(c1)/d;
Bb=2*pi*nb*b*cos(c2)/d;Bc=2*pi*nc*c*cos(cc)/d;
Bd=2*pi*nd*dd*cos(cd)/d;
f=4*pi*1e-7;
e=1e-9/(36*pi);
m=sqrt(e/f);
za=m*cos(c1)*na;zb=m*cos(c2)*nb;z1=f*cos(c3)*n1;z2=f*cos(c4)*n2;
zc=m*cos(cc)*nc;zd=m*cos(cd)*nd;
p1=cos(Bb);p2=-i*sin(Bb)/zb;p3=-i*zb*sin(Bb);p4=cos(Bb);
P=[p1 p2;p3 p4];
q1=cos(Ba);q2=-i*sin(Ba)/za;q3=-i*za*sin(Ba);q4=cos(Ba);
Q=[q1 q2;q3 q4];
c1=cos(Bc);c2=-i*sin(Bc)/zc;c3=-i*zc*sin(Bc);c4=cos(Bc);C=[c1 c2;c3 c4];
d1=cos(Bd);d2=-i*sin(Bd)/zd;d3=-i*zb*sin(Bd);d4=cos(Bd);D=[d1 d2;d3 d4];
O1=Q*P*Q*P*C*P*Q*D*Q*D *C* D*Q*D*Q*P*C*P*Q*P*Q;
O11=O1(1,1);O12=O1(1,2);O13=O1(2,1);O14=O1(2,2);
z1=sqrt(e/f)*n1*cos(c3);z2=sqrt(e/f)*n2*cos(c4);
t=2*z1/(z1*(O11+z2*O12)+O13+z2*O14);
r=(z1*(O11+z2*O12)-O13-z2*O14)/(z1*(O11+z2*O12)+O13+z2*O14);
t1=abs(t);
r1=abs(r);
s=d-1099;
k(1,s)=t1;
end
d=1100:1800;
plot(d,k)
另polt后面加不加分号有关系吗?
matlab中的问题此程序没错na=2.10;nb=1.46;n1=1;n2=1;for d=400:1600;c3=0;c1=asin(n1*sin(c3)/na);c2=asin(na*sin(c1)/nb);c4=asin(nb*sin(c2)/n2);d1=1064;a=d1/(4*na);b=d1/(4*nb);Ba=2*pi*na*a*cos(c1)/d;Bb=2*pi*nb*b*cos(c2)/d;f=4*pi*1e-7;e=1e-9/(36*p
没什么错误,你的变量混了!我先运行原来的程序,然后再把d,d1的值改掉再运行,会出现和楼主一样的错误.检查变量后发现,d最终为1*701,而k最终为1*1201,可以看出,该k合第一次运行程序中的k混了,所以clear all 一下,直接运行改掉d,d1值的程序即可.
plot只是画图命令,加不加分号,无所谓.
运行结果如图: