matlab :Subscript indices must either be real positive integers or logicalsn(1)=1;n(2)=2;n(3)=3;n(4)=4;n(5)=1;h(1)=0.02;h(2)=0.03;h(3)=0.04;for i=1:3;sita(1)=1; sita(i+1)=asin(sin(sita(i))*n(i)/n(i+1));cos(sita(i))=(1-sin(sita(i))^2)^0.5;f=1.6e10;n
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 08:31:44
matlab :Subscript indices must either be real positive integers or logicalsn(1)=1;n(2)=2;n(3)=3;n(4)=4;n(5)=1;h(1)=0.02;h(2)=0.03;h(3)=0.04;for i=1:3;sita(1)=1; sita(i+1)=asin(sin(sita(i))*n(i)/n(i+1));cos(sita(i))=(1-sin(sita(i))^2)^0.5;f=1.6e10;n
matlab :Subscript indices must either be real positive integers or logicals
n(1)=1;
n(2)=2;
n(3)=3;
n(4)=4;
n(5)=1;
h(1)=0.02;
h(2)=0.03;
h(3)=0.04;
for i=1:3;
sita(1)=1;
sita(i+1)=asin(sin(sita(i))*n(i)/n(i+1));
cos(sita(i))=(1-sin(sita(i))^2)^0.5;
f=1.6e10;
namta=3e8/f;
fai=(4*pi/namta)*n(i)*h(i)*cos(sita(i));
Mt=[];
Mt(1,1)=cos(fai);
Mt(1,2)=-sqrt(-1)*sin(fai)/n(i);
Mt(2,1)=-sqrt(-1)*sin(fai)*n(i);
Mt(2,2)=cos(fai);
M=[1 0;0 1];
Mt=M*Mt;
end
H=[1 n(4)];
Y=Mt*H;
K=Y(2)/Y(1);
r=(n(1)*cos(sita(1))-K*cos(sita(i+1)))/(n(1)*cos(sita(1))+K*cos(sita(i+1)));
T=1-r^2;
错误提示:
Subscript indices must either be real positive integers or logicals.
Error in sanceng (line 22)Mt(1,1)=cos(fai);
这个程序要怎么改啊 这行就没下标啊
matlab :Subscript indices must either be real positive integers or logicalsn(1)=1;n(2)=2;n(3)=3;n(4)=4;n(5)=1;h(1)=0.02;h(2)=0.03;h(3)=0.04;for i=1:3;sita(1)=1; sita(i+1)=asin(sin(sita(i))*n(i)/n(i+1));cos(sita(i))=(1-sin(sita(i))^2)^0.5;f=1.6e10;n
n=[1 2 3 4 1];h=[0.02 0.03 0.04];
for i=1:3;
sita(1)=1;
sita(i+1)=asin(sin(sita(i))*n(i)/n(i+1));
sita(i)=acos((1-sin(sita(i))^2)^0.5); %用反余弦
f=1.6e10;namta=3e8/f;
fai=(4*pi/namta)*n(i)*h(i)*cos(sita(i));
Mt=[];
Mt(1,1)=cos(fai);
Mt(1,2)=-sqrt(-1)*sin(fai)/n(i);
Mt(2,1)=-sqrt(-1)*sin(fai)*n(i);
Mt(2,2)=cos(fai);
M=[1 0;0 1];
Mt=M.*Mt; %这里要用点乘
end
H=[1 n(4); 1 1]; %这里要将 H 定义为 2x2 矩阵
Y=Mt.*H; %用点乘
K=Y(2)/Y(1);
r=(n(1)*cos(sita(1))-K*cos(sita(i+1)))/(n(1)*cos(sita(1))+K*cos(sita(i+1)));
T=1-r^2;