a2=axes('Position',[0.4,0.16,0.4,0.7]) %图片滚则在figure中的位置 前两个代表x方向的坐标,后两个是y方向的凯备敏坐标
[x,y]=meshgrid(linspace(-0.005,0.005,200))%%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%rgb 色彩取值
cg=1-cr
cb=abs(L-600)/240
Ik(:,:,1)=In*cr %颜色的设置
Ik(:,:,2)=In*cg
Ik(:,:,3)=In*cb
Pc=imshow(Ik,[]) %显示图片
% 牛顿环演示的MATLAB程序close allclearclc
figure('Position',[90 164 873 483])
L=632.8R=5H=5
a1=axes('Position',[0.83,0.3,0.15,0.4])
hold onaxis([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)/200cg=1-cr',...
'cb=abs(L-600)/240Ik(:,:,1)=In*crIk(:,:,2)=In*cg',...
'Ik(:,:,3)=In*cbset(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)/200cg=1-cr',...
'cb=abs(L-600)/240Ik(:,:,1)=In*crIk(:,:,2)=In*cg',...
'Ik(:,:,3)=In*cbset(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)/200cg=1-cr',...
'cb=abs(L-600)/240Ik(:,:,1)=In*crIk(:,:,2)=In*cg',...
'Ik(:,:,3)=In*cbset(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')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)