如果想计算更准确,可燃腔芹以用符号函数求解0点。符号函数不用关心具体的函数值,完全当做符号处理,所以,不存在上述不稳定因素。圆好
其码昌实很简单,读其中一行即可(仅限迟搜扒于线状干涉图) I=imread('test2.jpg')I = rgb2gray(I)I = histeq(I)[m,n]=size(I)r = I(fix(m/2),:)%读取图像中漏磨间一行plot(r)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))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)