Matlab实例

1、从光疏介质射入光密介质(n1 = 1,n2 = 1.5)

clear;
clc; 
theta1 = 0:pi/20:pi/2;     %theta1 is an angle of incidence 
%光由光疏介质射入光密介质
n1 = 1;
n2 = 1.5;
n = n1/n2;
Y0 = 0 * theta1; %参考0轴
% theta2 = asin(n1*sin(theta1));%theta1 is a refraction angle
rs = (n*cos(theta1)-sqrt(1-n.^2*(sin(theta1)).^2))./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));   
rp = (cos(theta1)-n*sqrt(1-n.^2*(sin(theta1)).^2))./(cos(theta1)+n*sqrt(1-(n*sin(theta1)).^2));
plot(theta1,rs,'b',theta1,rp,'r',theta1,Y0,'b');    %rs&rp曲线
%%%%%%%%%%%%%%%%%%
hold on;
ts = 2*n*cos(theta1)./(cos(theta1)+n*sqrt(1-(n*sin(theta1).^2)));
tp = 2*n*cos(theta1)./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));
plot(theta1,ts,'g',theta1,tp,'b');  %ts&tp曲线
%标注
h = text(0,-0.2,' \leftarrow rs');
set(h,'Fontsize',16);
h = text(0,0.2,' \leftarrow rp');
set(h,'Fontsize',16);
h = text(1,2*n*cos(1)./(cos(1)+n*sqrt(1-(n*sin(1).^2))),' \leftarrow ts');
set(h,'Fontsize',16);
h = text(1,2*n*cos(1)./(n*cos(1)+sqrt(1-(n*sin(1)).^2)),' \leftarrow tp');
set(h,'Fontsize',16);
legend('rs','rp','tp','ts');  
axis([0,pi/2,-1,1]);    %限制坐标轴的范围
set(gca,'XTick',0:pi/20:pi/2);%%设置标度:设置X轴最小标度为pi/20
set(gca,'YTick',-1:0.2:1);%%设置标度:设置Y轴最小标度为0.4
grid on;
xlabel('theta1');
title('高光作业-从光疏介质射入光密介质');

这里写图片描述

2、从光密介质射入光疏介质(n1 = 1.5,n2 = 1)

clear;
clc; 
%光由光疏介质射入光密介质
n1 = 1.5;
n2 = 1;
n = n1/n2;
theta1 = 0:pi/20:asin(n2/n1);     %之后是全反射现象n1sintheta1 = n2sin90
Y0 = 0 * theta1; %参考0轴
hold on;
% theta2 = asin(n1*sin(theta1));%theta1 is a refraction angle
rs = (n*cos(theta1)-sqrt(1-n.^2*(sin(theta1)).^2))./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));   
rp = (cos(theta1)-n*sqrt(1-n.^2*(sin(theta1)).^2))./(cos(theta1)+n*sqrt(1-(n*sin(theta1)).^2));
plot(theta1,rs,'b',theta1,rp,'r');    %rs&rp曲线
%%%%%%%%%%%%%%%%%%
hold on;
ts = 2*n*cos(theta1)./(cos(theta1)+n*sqrt(1-(n*sin(theta1).^2)));
tp = 2*n*cos(theta1)./(n*cos(theta1)+sqrt(1-(n*sin(theta1)).^2));
plot(theta1,ts,'g',theta1,tp,'M');  %ts&tp曲线
%标注
h = text(0.45,(n*cos(0.45)-sqrt(1-n.^2*(sin(0.45)).^2))./(n*cos(0.45)+sqrt(1-(n*sin(0.45)).^2)),' \leftarrow rs');
set(h,'Fontsize',16);
h = text(0.5,(cos(0.5)-n*sqrt(1-n.^2*(sin(0.5)).^2))./(cos(0.5)+n*sqrt(1-(n*sin(0.5)).^2)),' \leftarrow rp');
set(h,'Fontsize',16);
h = text(0.45,2*n*cos(0.45)./(cos(0.45)+n*sqrt(1-(n*sin(0.45).^2))),' \leftarrow ts');
set(h,'Fontsize',16);
h = text(0.6,2*n*cos(0.6)./(n*cos(0.6)+sqrt(1-(n*sin(0.6)).^2)),' \leftarrow tp');
set(h,'Fontsize',16);
legend('rs','rp','ts','tp');    %标注
theta = 0:0.3:1.2;
plot(theta,Y0,'black');
axis([0,0.95,-1,2]);    %限制坐标轴的范围
set(gca,'XTick',0:pi/20:0.95);%%设置标度:设置X轴最小标度为pi/20
set(gca,'YTick',-1:0.3:2);%%设置标度:设置Y轴最小标度为0.4
grid on;
xlabel('theta1');
title('高光作业-从光密介质射入光疏介质');

这里写图片描述

  • 5
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值