程序及运行
function function_2_1
n0=input('enter n0=');
n1=input('enter n1=');%纤维的折光系数
r=input('enter r=');%异形截面纤维轮廓中心基圆的半径
r1=input('enter r1=');%异形截面纤维轮廓顶端基圆的半径
R=input('enter R=');%异形截面纤维轮廓外接基圆的半径
I0=input('enter I0=');%入射光的光强
n=input('enter n=');%theta0的等分个数
m=input('enter m=');%thetat的等分个数
t=asin((r-r1)/(R-r1));%AB直线部分与Y轴正向的夹角
thetat=(pi/2)-t;%AB直线部分光线的法线与Y轴正向的夹角
lAB=sqrt((R-r1).^2-(r-r1).^2);%AB直线部分长度
theta0=0;deltatheta0=((pi/2)-0)/m;%入射光的初始角赋值和theta0的等分角度
while (theta0<=(pi/2))
k=0:m;
theta0=theta0+k*(deltatheta0);
thetaR2=thetat-theta0;
feR2=asin((n0*sin(thetaR2))/n1);
Rr2=(1/2)*(((tan(thetaR2-feR2).^2)/(tan(thetaR2+feR2).^2))+((sin(thetaR2-feR2).^2)/(sin(thetaR2+feR2).^2)));
Ir2=(I0*Rr2*sin(thetaR2))/lAB;
k=k+1;
end
x1=0:0.01

pi/2);
y1=0:0.01

(pi/2)-t);
[x,y]=meshgrid(x1,y1);
z=Ir2;
surf(x,y,z)
colormap,colorbar
>> function_2_1()
enter n0=1
enter n1=1.5
enter r=2
enter r1=1
enter R=5
enter I0=1
enter n=0
enter m=157
Warning: Matrix dimensions must agree, not rendering mesh.
多谢了