日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【物理应用】基于Matlab模拟杨氏双孔干涉实验

發布時間:2023/12/29 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【物理应用】基于Matlab模拟杨氏双孔干涉实验 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1 內容介紹

根據光的雙縫干涉實驗理論,利用MATLAB編寫程序對雙縫干涉實驗進行模擬,繪制出雙縫干涉的圖樣和光強分布曲線,并且同步計算出相應的條紋間距和對比度,直觀地展現了單色光的雙縫干涉這一物理現象,實驗結果與實際計算結果一致,為雙縫干涉的理論與實驗提供了有效的支持.

2 部分代碼

function varargout = ganshe(varargin)

% GANSHE M-file for ganshe.fig

%? ? ? GANSHE, by itself, creates a new GANSHE or raises the existing

%? ? ? singleton*.

%

%? ? ? H = GANSHE returns the handle to a new GANSHE or the handle to

%? ? ? the existing singleton*.

%

%? ? ? GANSHE('CALLBACK',hObject,eventData,handles,...) calls the local

%? ? ? function named CALLBACK in GANSHE.M with the given input arguments.

%

%? ? ? GANSHE('Property','Value',...) creates a new GANSHE or raises the

%? ? ? existing singleton*.? Starting from the left, property value pairs are

%? ? ? applied to the GUI before ganshe_OpeningFcn gets called.? An

%? ? ? unrecognized property name or invalid value makes property application

%? ? ? stop.? All inputs are passed to ganshe_OpeningFcn via varargin.

%

%? ? ? *See GUI Options on GUIDE's Tools menu.? Choose "GUI allows only one

%? ? ? instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ganshe

% Last Modified by GUIDE v2.5 21-Jun-2014 11:31:04

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',? ? ? ?mfilename, ...

? ? ? ? ? ? ? ? ? ?'gui_Singleton',? gui_Singleton, ...

? ? ? ? ? ? ? ? ? ?'gui_OpeningFcn', @ganshe_OpeningFcn, ...

? ? ? ? ? ? ? ? ? ?'gui_OutputFcn',? @ganshe_OutputFcn, ...

? ? ? ? ? ? ? ? ? ?'gui_LayoutFcn',? [] , ...

? ? ? ? ? ? ? ? ? ?'gui_Callback',? ?[]);

if nargin && ischar(varargin{1})

? ? gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

? ? [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

? ? gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before ganshe is made visible.

function ganshe_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject? ? handle to figure

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% varargin? ?command line arguments to ganshe (see VARARGIN)

% Choose default command line output for ganshe

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes ganshe wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = ganshe_OutputFcn(hObject, eventdata, handles)?

% varargout? cell array for returning output args (see VARARGOUT);

% hObject? ? handle to figure

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit1 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.

function edit1_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit1 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

function edit2_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit2 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.

function edit2_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit2 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

function edit3_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit3 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties.

function edit3_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit3 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

function edit4_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit4 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties.

function edit4_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit4 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

% --- Executes during object creation, after setting all properties.

function edit6_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit6 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

function edit7_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit7 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit7 as a double

% --- Executes during object creation, after setting all properties.

function edit7_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit7 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

function edit8_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit8 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit8 as a double

% --- Executes during object creation, after setting all properties.

function edit8_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit8 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

function edit9_Callback(hObject, eventdata, handles)

% hObject? ? handle to edit9 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit9 as text

%? ? ? ? str2double(get(hObject,'String')) returns contents of edit9 as a double

% --- Executes during object creation, after setting all properties.

function edit9_CreateFcn(hObject, eventdata, handles)

% hObject? ? handle to edit9 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%? ? ? ?See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

? ? set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject? ? handle to pushbutton1 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

%讀入實驗參數

lambda=str2num(get(handles.edit1,'string'))*1e-9;? %讀入波長

d=str2num(get(handles.edit2,'string'))*1e-3;? ? ? ?%讀入孔距

D=str2num(get(handles.edit3,'string'));? ? ? ? ? ? %讀入觀察屏距離

%讀入觀察范圍參數

xa=str2num(get(handles.edit4,'string'));? ? ?%最小的橫坐標值

xb=str2num(get(handles.edit5,'string'));? ? ?%最大的橫坐標值

n1=str2num(get(handles.edit6,'string'));? ? ?%x方向等分份數

ya=str2num(get(handles.edit7,'string'));? ? ?%最小的縱坐標值

yb=str2num(get(handles.edit8,'string'));? ? ?%最大的縱坐標值

n2=str2num(get(handles.edit9,'string'));? ? ?%y方向等分份數

k=2*pi/lambda;? ? ? ? ? %計算波數

x=linspace(xa,xb,n1);? ?%x坐標

y=linspace(ya,yb,n2);? ?%y坐標

[x,y]=meshgrid(x,y);

r1=sqrt((x-d/2).^2+y.^2+D^2);

r2=sqrt((x+d/2).^2+y.^2+D^2);

I=(cos(k*r1)./r1+cos(k*r2)./r2).^2+(sin(k*r1)./r1+sin(k*r2)./r2).^2;

I=I/(max(max(I)));?

I=I*255;

axes(handles.axes1)

x=linspace(xa,xb,n1);

y=linspace(ya,yb,n2);

image(x,y,I)

colormap(gray(255))

xlabel('x (m)')

ylabel('y (m)')

title('楊氏雙孔干涉條紋')

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject? ? handle to pushbutton2 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles)

% hObject? ? handle to pushbutton3 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

3 運行結果

4 參考文獻

[1]盛虹. 基于MATLAB的楊氏雙縫干涉實驗模擬[J]. 河南科學, 2010, 28(6):3.

博主簡介:擅長智能優化算法、神經網絡預測、信號處理、元胞自動機、圖像處理、路徑規劃、無人機、雷達通信、無線傳感器等多種領域的Matlab仿真,相關matlab代碼問題可私信交流。

部分理論引用網絡文獻,若有侵權聯系博主刪除。

總結

以上是生活随笔為你收集整理的【物理应用】基于Matlab模拟杨氏双孔干涉实验的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。