Use matlab para dibujar diagramas de intensidad de transmisión y reflexión en diferentes ángulos

El código analiza los casos de vidrio a aire y de aire a vidrio por separado. Para satisfacer las necesidades de precisión, también se utilizan pasos variables en lugares clave.

clc;clear;close all;
%入射 th1 折射 th2
syms rs ts rp tp
th1 = 0:0.001:pi/2;
n1 = 1;n2 = 1.5; n = n1/n2;
% 当从空气中入射玻璃时
sinth2 = sin(th1).*n;
costh2 = sqrt(1-sinth2.^2);
ts = 2*n1.*cos(th1)./(n1.*cos(th1)+n2.*costh2);
rs = ts-1;
figure;
plot(th1,ts, 'LineWidth',2);hold on; 
plot(th1,rs, 'LineWidth',2);hold on; 

tp = 2*n1.*cos(th1)./(n2.*cos(th1)+n1.*costh2);
rp = (n2/n1).*tp-1;
plot(th1,tp, 'LineWidth',2);hold on; 
plot(th1,rp, 'LineWidth',2);hold on; 
% 辅助线绘制
legend('ts','rs','tp','rp');legend('boxoff');
title('从空气中入射玻璃');
x = [0,1.6];
y = [rp(end),rp(end)];
plot(x,y,'HandleVisibility','off','Color','k','LineStyle','--');hold on;
x = [0,1.6];
y = [tp(end),tp(end)];
plot(x,y,'HandleVisibility','off','Color','k','LineStyle','--');hold on;


clear;figure;
syms rs ts rp tp
% 当从玻璃入射空气时
n1 = 1.5;n2 = 1; n = n1/n2;
limth1 = asin(n2/n1);%全反射角的初步计算
p1 = 0:0.01:0.728;
p2 = 0.728:0.00000001:0.73;
p3 = 0.73:0.01:pi/2;%变步长计算
th1  = [p1 p2 p3];
sinth2 = sin(th1).*n;
index = find(sinth2>1 | sinth2 == 1);
sinth2(index) = 0;
costh2 = sqrt(1-sinth2.^2);
ts = 2*n1.*cos(th1)./(n1.*cos(th1)+n2.*costh2);
ts(index) = NaN;% 无意义部分的截取
rs = ts-1;
plot(th1,ts, 'LineWidth',2);hold on;
plot(th1,rs, 'LineWidth',2);hold on;

tp = 2*n1.*cos(th1)./(n2.*cos(th1)+n1.*costh2);
rp = (n2/n1).*tp-1; x1 = th1(index(1));
tp(index) = NaN;% 无意义部分的截取
rp(index) = rp(index(1)-1);
plot(th1,tp, 'LineWidth',2);hold on;
plot(th1,rp, 'LineWidth',2);hold on;
% 辅助线绘制
legend('ts','rs','tp','rp');legend('boxoff')
title('从玻璃入射空气');
x=[x1,x1];y=[-1,3.5]; 
plot(x,y,'HandleVisibility','off','Color','k','LineStyle','--');hold on;
x=[0,x1];y=[rp(index(1)-1),rp(index(1)-1)]; 
plot(x,y,'HandleVisibility','off','Color','k','LineStyle','--');hold on;
mark  = find(abs(rp)<0.01);
x = [th1(mark),th1(mark)];y=[-1,0];
plot(x,y,'HandleVisibility','off','Color','k','LineStyle','--');hold on;
x = [0,th1(mark)];y=[0,0];
plot(x,y,'HandleVisibility','off','Color','k','LineStyle','--');hold on;

largo.

Supongo que te gusta

Origin blog.csdn.net/qq_49003248/article/details/129558380
Recomendado
Clasificación