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/08/28 02:25:58
![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](/uploads/image/z/2542431-39-1.jpg?t=matlab%E4%B8%AD%E7%9A%84%E9%97%AE%E9%A2%98%E6%AD%A4%E7%A8%8B%E5%BA%8F%E6%B2%A1%E9%94%99na%3D2.10%3Bnb%3D1.46%3Bn1%3D1%3Bn2%3D1%3Bfor+d%3D400%3A1600%3Bc3%3D0%3Bc1%3Dasin%28n1%2Asin%28c3%29%2Fna%29%3Bc2%3Dasin%28na%2Asin%28c1%29%2Fnb%29%3Bc4%3Dasin%28nb%2Asin%28c2%29%2Fn2%29%3Bd1%3D1064%3Ba%3Dd1%2F%284%2Ana%29%3Bb%3Dd1%2F%284%2Anb%29%3BBa%3D2%2Api%2Ana%2Aa%2Acos%28c1%29%2Fd%3BBb%3D2%2Api%2Anb%2Ab%2Acos%28c2%29%2Fd%3Bf%3D4%2Api%2A1e-7%3Be%3D1e-9%2F%2836%2Ap)
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只是画图命令,加不加分号,无所谓.
运行结果如图: