⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newtonhuan.txt

📁 这个程序可以实现牛顿环(Newton s rings)的演示, 其中可调参数包括波长, 透镜曲率半径及最低点空气缝隙的厚度.参数的调节是通过欢快实现的,其中颜色 随波长近似的变化. 本程序可以增进
💻 TXT
字号:
摘要: 这个程序可以实现牛顿环(Newton's rings)的演示, 其中可调参数包括波长,
透镜曲率半径及最低点空气缝隙的厚度.参数的调节是通过欢快实现的,其中颜色
随波长近似的变化. 本程序可以增进读者对牛顿环的理解.
 
程序如下:

% 牛顿环演示的MATLAB程序
close all;clear;clc;
figure('Position',[90 164 873 483]);
L=632.8;R=5;H=5;
a1=axes('Position',[0.83,0.3,0.15,0.4]);
hold on;axis([0,1,0,1]);
plot([0.25,0.25],[0.5,0.8],'k');
plot([0.5,0.5],[0.5,0.8],'k');
plot([0.75,0.75],[0.5,0.8],'k');
fill([0.22,0.25,0.27],[0.5,0.44,0.5],'k');
fill([0.47,0.5,0.52],[0.5,0.44,0.5],'k');
fill([0.72,0.75,0.77],[0.5,0.44,0.5],'k');
z=1.8*exp(i*(linspace(-0.21,0.21,30)-pi/2))+2.1*i+0.5;
fill(real(z),imag(z),'w');
rectangle('Position',[0.1,0.18,0.8,0.12]);
set(gca,'xtick',[],'ytick',[],'box','on');
% \copyright: zjliu
% Author's email: zjliu2001@163.com
a2=axes('Position',[0.4,0.16,0.4,0.7]);
[x,y]=meshgrid(linspace(-0.005,0.005,200));
r2=(x.^2+y.^2);
Di=[2*H+2*(R-sqrt(R^2-r2))*1e9]/L;
In=abs(cos(Di*pi*2));
cr=abs(L-560)/200;
cg=1-cr;
cb=abs(L-600)/240;
Ik(:,:,1)=In*cr;
Ik(:,:,2)=In*cg;
Ik(:,:,3)=In*cb;
Pc=imshow(Ik,[]);
title('the pattern of Newton''s rings','fontsize',18);
Lt=uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.06,0.86,0.21,0.06],... 
  'BackgroundColor',0.7*[1,1,1],'ForegroundColor',[0.8,0.1,0.9],... 
  'string','波长: 632.8nm','fontsize',16,'fontname','times new roman');
s1=uicontrol(gcf,'style','slider',... 
  'unit','normalized','position',[0.06,0.76,0.21,0.04],... 
  'BackgroundColor',0.7*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'SliderStep',[0.01,0.01],'value',(632.8-360)/400,...
  'callback',['L=get(s1,''value'')*400+360;',...
  'set(Lt,''string'',[''波长: '',num2str(L/10),''nm'']);',...
  'Di=[2*H+2*(R-sqrt(R^2-r2))*1e9]/L;',...
  'In=abs(cos(Di*pi*2));cr=abs(L-560)/200;cg=1-cr;',...
  'cb=abs(L-600)/240;Ik(:,:,1)=In*cr;Ik(:,:,2)=In*cg;',...
  'Ik(:,:,3)=In*cb;set(Pc,''CData'',Ik);']);

uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.04,0.81,0.08,0.04],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'string','360','fontsize',16,'fontname','times new roman');
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.22,0.81,0.08,0.04],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'string','760','fontsize',16,'fontname','times new roman');

Rt=uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.06,0.66,0.23,0.06],... 
  'BackgroundColor',0.7*[1,1,1],'ForegroundColor',[0.8,0.1,0.9],... 
  'string','曲率半径:','fontsize',16,'fontname','times new roman');
s2=uicontrol(gcf,'style','slider',... 
  'unit','normalized','position',[0.06,0.56,0.21,0.04],... 
  'BackgroundColor',0.7*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'SliderStep',[0.01,0.01],...
  'callback',['R=get(s2,''value'')*7+5;',...
  'set(Rt,''string'',[''曲率半径: 5m'',num2str(R),''m'']);',...
  'Di=[2*H+2*(R-sqrt(R^2-r2))*1e9]/L;',...
  'In=abs(cos(Di*pi*2));cr=abs(L-560)/200;cg=1-cr;',...
  'cb=abs(L-600)/240;Ik(:,:,1)=In*cr;Ik(:,:,2)=In*cg;',...
  'Ik(:,:,3)=In*cb;set(Pc,''CData'',Ik);']);
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.04,0.61,0.08,0.04],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'string','5','fontsize',16,'fontname','times new roman');
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.22,0.61,0.08,0.04],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'string','12','fontsize',16,'fontname','times new roman');

Ht=uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.06,0.46,0.23,0.06],... 
  'BackgroundColor',0.7*[1,1,1],'ForegroundColor',[0.8,0.1,0.9],... 
  'string','气缝厚度: 5nm','fontsize',16,'fontname','times new roman');
s3=uicontrol(gcf,'style','slider',... 
  'unit','normalized','position',[0.06,0.36,0.21,0.04],... 
  'BackgroundColor',0.7*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'SliderStep',[0.01,0.01],'value',0.05,...
  'callback',['H=get(s3,''value'')*100;',...
  'set(Ht,''string'',[''气缝厚度: '',num2str(H),''nm'']);',...
  'Di=[2*H+2*(R-sqrt(R^2-r2))*1e9]/L;',...
  'In=abs(cos(Di*pi*2));cr=abs(L-560)/200;cg=1-cr;',...
  'cb=abs(L-600)/240;Ik(:,:,1)=In*cr;Ik(:,:,2)=In*cg;',...
  'Ik(:,:,3)=In*cb;set(Pc,''CData'',Ik);']);
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.04,0.41,0.08,0.04],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'string','0','fontsize',16,'fontname','times new roman');
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.22,0.41,0.08,0.04],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.1,0.1,0.9],... 
  'string','100','fontsize',16,'fontname','times new roman');
%%%% Note
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.05,0.08,0.68,0.07],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.8,0.2,0.2],... 
  'string','颜色和波长的关系可能不准确,我只是根据大致的关系写的',...
  'fontsize',16,'fontname','times new roman');
uicontrol(gcf,'style','text',... 
  'unit','normalized','position',[0.05,0.02,0.6,0.07],... 
  'BackgroundColor',0.8*[1,1,1],'ForegroundColor',[0.9,0.2,0.5],... 
  'string','\Copyright zjliu,  email: zjliu2001@163.com',...
  'fontsize',16,'fontname','times new roman');




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -