matlab的几个干涉实验模拟

matlab的几个干涉实验模拟,第1张

function photo_diffraction

%光学衍射仿真 矩形

lmda=632.8e-9% 波长

xmax=0.05% 观察屏所取范围

a=1e-3f=1

ymax=xmax

def=0.0001

x=-xmax:def:xmax

y=-ymax:def:ymax

lenm=length(x)

lenn=length(y)

for m=1:lenm

for n=1:lenn

alpha=pi*x(m)*a/(lmda*f)%0.5*k*l*a

beta=pi*y(n)*a/(lmda*f)%bb=0.5*k*w*b

I(m,n)=((sin(alpha))/(alpha))^2*((sin(beta))/(beta))^2

end

end

I=I/(max(max(I)))

[X,Y]=meshgrid(x,y)

figure

mesh(X,Y,I)

xlabel('x')

ylabel('y')

zlabel(' 光强')

rotate3D

hold on

figure

imshow(255*I)

xlabel('x')

ylabel('y')

%---------光学衍射仿真 单缝------------

clear

lam=500e-9

a= 1e-3f=1

xm= 3*lam*f/a

nx= 51

xs=linspace(-xm,xm,nx)

np=51

xp=linspace(0,a,np)

for i=1:nx

sinphi= xs(i)/f

alpha=2*pi*xp*sinphi/lam

sumcos=sum(cos(alpha))

sumsin=sum(sin(alpha))

B(i,:)=(sumcos^2+sumsin^2)/np^2

end

N=255

Br=(B/max(B))*N

figure

subplot(1,2,1)

image(xm,xs,Br)

colormap(gray(N))

subplot(1,2,2)

plot(B,xs)

%--------光学衍射仿真 多缝--------------

clear

lam=500e-9N=2

a= 2e-4z=5d=5*a

xm=2*lam*z/ay0=xm

n=1001

x0=linspace(-xm,xm,n)

for i= 1: n

sinphi=x0(i)/z

alpha=pi*a*sinphi/lam

beta=pi*d*sinphi/lam

B(i,:)=(sin(alpha)./alpha).^2.*(sin(N*beta)./sin(beta)).^2

B1=B/max(B)

end

NC=255

Br=(B/max(B))*NC

figure

subplot(1,2,1)

image(y0,x0,Br)

colormap( gray(NC) )

subplot(1,2,2)

plot(B1,x0)

%--------光学衍射仿真 圆孔--------------

clear

lam=500% '请输入光的波长:')

lam=lam*1e-9

a=2e-3

f=1

m=200

ym=2000*lam*f

ys=linspace(-ym,ym,m)

xs=ys

n=255

for i=1:m

r=xs(i)^2+ys.^2

sinth=sqrt(r./(r+f^2))

x=2*pi*a*sinth./lam

hh=(2*BESSELJ(1,x)).^2./x.^2

b(:,i)=(hh)'.*5000

end

figure

subplot(1,2,1)

image(xs,ys,b)

colormap(gray(n))

subplot(1,2,2)

b(:,m/2)

plot(ys,b(:,m/2))

%入射光在X-Z平面内传播的两束光平面光波干涉。Z轴为传播方向。

clear all

close all

%参数设置

Lamda=532*10e-6

KK=2*pi/Lamda

AngleOneX=2 %与Z方向夹角

AngleTwoX=-2

AngleOneY=90 %与Y方向夹角

AngleTwoY=-90

AngleOneX=pi/180*AngleOneX AngleOneY=pi/180*AngleOneY

AngleTwoX=pi/180*AngleTwoX AngleTwoY=pi/180*AngleTwoY

ViewUp=100*Lamda

ViewDown=-100*Lamda

Space=0.1*Lamda %N=1000

[ViewX,ViewY]=meshgrid(ViewDown:Space:ViewUp)

%两束光的光场分布

FieldOne1=exp(1i*(KK*sin(AngleOneX).*ViewX+KK*cos(AngleOneY).*ViewY))

FieldTwo1=exp(1i*(KK*sin(AngleTwoX).*ViewX+KK*cos(AngleTwoY).*ViewY))

Intensity1=(FieldOne1+FieldTwo1).*conj(FieldOne1+FieldTwo1)

figure

subplot(2,2,1)

imshow(Intensity1,[])


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8104630.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存