⛄一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【光学】基于matlab GUI菲涅尔系数计算【含Matlab源码 1165期】
点击上面蓝色字体,直接付费下载,即可。
获取代码方式2:
付费专栏Matlab物理应用(初级版)
备注:
点击上面蓝色字体付费专栏Matlab物理应用(初级版),扫描上面二维码,付费29.9元订阅海神之光博客付费专栏Matlab物理应用(初级版),凭支付凭证,私信博主,可免费获得1份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:1份本博客上传CSDN资源代码
⛄二、菲涅尔系数计算简介
基于matlab GUI菲涅尔系数计算:通过平面波反射系数演示,解释不儒斯特角,展示垂直极化系数与水平极化系数的幅度和相位关系。
⛄三、部分源代码
function varargout = Fresnel(varargin)
% FRESNEL MATLAB code for Fresnel.fig
% FRESNEL, by itself, creates a new FRESNEL or raises the existing
% singleton*.
%
% H = FRESNEL returns the handle to a new FRESNEL or the handle to
% the existing singleton*.
%
% FRESNEL(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in FRESNEL.M with the given input arguments.
%
% FRESNEL(‘Property’,‘Value’,…) creates a new FRESNEL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Fresnel_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Fresnel_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 Fresnel
% Last Modified by GUIDE v2.5 28-May-2021 12:02:27
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @Fresnel_OpeningFcn, …
‘gui_OutputFcn’, @Fresnel_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 Fresnel is made visible.
function Fresnel_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 Fresnel (see VARARGIN)
% Choose default command line output for Fresnel
set(handles.uipanel11,‘Visible’,‘off’);
set(handles.uipanel7,‘Visible’,‘on’);
set(handles.uipanel8,‘Visible’,‘on’);
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Fresnel wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = Fresnel_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;
% — Executes on button press in radiobutton_Rs.
function radiobutton_Rs_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton_Rs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of radiobutton_Rs
% — Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of radiobutton2
% — Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of radiobutton3
% — Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of radiobutton4
% — Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of radiobutton5
% — Executes on button press in radiobutton6.
function radiobutton6_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,‘Value’) returns toggle state of radiobutton6
% — 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)
n1 = str2double(get(handles.edit_n1,‘String’));
n2 = str2double(get(handles.edit_n2,‘String’));
if isnan(n1)
errordlg(‘Input must be a number’,‘Error’);
end
if isnan(n2)
errordlg(‘Input must be a number’,‘Error’);
end
Incidence = pi/2;%入射角范围
d = 0.1*pi/180;
xx = 0:d:Incidence;%入射角
%画图的横坐标
X = xx.*180/pi;
Transmission = asin((n1sin(xx))./n2);%透射角
[ver,hor] = find((n1sin(xx))./n2 > 1);%大于全反射角置零
Transmission(ver,hor) = 0;
%选择输出参数
line_rs = get(handles.radiobutton_rrs,‘Value’);
line_rp = get(handles.radiobutton_rp,‘Value’);
line_ts = get(handles.radiobutton_ts,‘Value’);
line_tp = get(handles.radiobutton_tp,‘Value’);
line_ps = get(handles.radiobutton_ps,‘Value’);
line_Ts = get(handles.radiobutton_Ts,‘Value’);
line_Tp = get(handles.radiobutton_Tp,‘Value’);
line_pp = get(handles.radiobutton_pp,‘Value’);
line_Tn = get(handles.radiobutton_Tn,‘Value’);
line_pn = get(handles.radiobutton_pn,‘Value’);
%计算透反射系数
rs = -sin(xx - Transmission)./sin(xx + Transmission);
ts = 2*sin(Transmission).cos(xx)./sin(xx + Transmission);
rp = tan(xx - Transmission)./tan(xx + Transmission);
tp = 2sin(Transmission).*cos(xx)./(sin(xx + Transmission).*cos(xx - Transmission));
%计算透反射比
ps = rs.*rs;
Ts = n2.*cosd(Transmission)./(n1.*cosd(xx)).*ts.*ts;
pp = rp.*rp;
Tp = n2.*cosd(Transmission)./(n1.*cosd(xx)).*tp.*tp;
%选择光波类型
Model = get(handles.popupmenu_model,‘Value’);%1为线偏光,2为自然光
if Model == 1 %线偏光
%绘图
%透、反射系数部分
axes(handles.axes1);
if line_rs == 1
plot(X,rs,'color','r');
hold on
end
if line_ts == 1
plot(X,ts,'color','m');
hold on
end
if line_rp == 1
plot(X,rp,'color','g');
hold on
end
if line_tp == 1
plot(X,tp,'color','c');
end
hold off
%透、反射比部分
axes(handles.axes2);
if line_ps == 1
plot(X,ps,'b');
hold on
end
if line_Ts == 1
plot(X,Ts,'y');
hold on
end
if line_pp == 1
plot(X,pp,'r');
end
if line_Tp == 1
plot(X,Tp,'g');
end
hold off
else%自然光
axes(handles.axes1);
cla reset
%set(handles.axes1,‘Visible’,‘off’)
pn = (ps + pp)./2;
Tn = 1 - pn;
⛄四、运行结果
⛄五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除