资源描述:
《matlab在基础物理学中的应用举例》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、Matlab在基础物理学中的应用举例(四)(光学:牛顿环的模拟)2011-02-1313:30:18
2、分类:MatlabSky
3、标签:matlab光学
4、字号大中小订阅下面是模拟牛顿环的图案,给出了一个用户交换操作界面的实现程序:closeall;clear;figure('Position',[90164873483]);%设置图形窗口位置L=632.8;R=5;H=0.005;%设置默认参数值:波长L、半径R和厚度Ha1=axes('Position',[0.83,0.3,0.15,0.4]);%设置坐标轴位置,在其上绘制简易的原理图holdon;axis([0,1,0,1])
5、;%设置坐标轴范围plot([0.25,0.25],[0.5,0.8],'r');%画竖直线,入射光线plot([0.5,0.5],[0.5,0.8],'r');%画竖直线,入射光线plot([0.75,0.75],[0.5,0.8],'r');%画竖直线,入射光线fill([0.22,0.25,0.27],[0.5,0.44,0.5],'r');%画出箭头fill([0.47,0.5,0.52],[0.5,0.44,0.5],'r');%画出箭头fill([0.72,0.75,0.77],[0.5,0.44,0.5],'r');%画出箭头z=1.8*exp(i*(linspac
6、e(-0.21,0.21,30)-pi/2))+2.1*i+0.5;%生成平凸透镜的轮廓fill(real(z),imag(z),'w');%利用fill函数画平凸透镜的轮廓rectangle('Position',[0.1,0.18,0.8,0.12]);%画玻璃板底面set(gca,'xtick',[],'ytick',[],'box','on');%删去坐标轴刻度a2=axes('Position',[0.4,0.16,0.4,0.7]);%生成第二个坐标轴,在其上画牛顿环[x,y]=meshgrid(linspace(-0.005,0.005,200));%生成坐标矩阵r
7、2=(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;%蓝色的分量值5Ik(:,:,1)=In*cr;%转化为RGB三基色表示颜色矩阵数值(红色)Ik(:,:,2)=In*cg;%转化为RGB三基色表示颜色矩阵数值(绿色)Ik(:,:,3)=In*cb;%转化为RGB三基色表示颜色矩阵数值(蓝色)Pc=imshow(Ik,
8、[]);%绘制缺省参数下的数值title('thepatternofNewton''srings','fontsize',12);%添加图题%实时显示波长的文本框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','wavelength:632.8nm','fontsize',12,'fontname','
9、timesnewroman');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'',['
10、'wavelength:'',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);']);%利用滑动条改变