【光学】基于matlab GUI菲涅尔系数计算【含Matlab源码 1165期】
【摘要】
一、获取代码方式
获取代码方式1: 完整代码已上传我的资源:【光学】基于matlab GUI菲涅尔系数计算【含Matlab源码 1165期】
获取代码方式2: 通过订阅紫极神光博客付费专栏,凭支付凭证...
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【光学】基于matlab GUI菲涅尔系数计算【含Matlab源码 1165期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、菲涅尔系数计算简介
基于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((n1*sin(xx))./n2);%透射角
[ver,hor] = find((n1*sin(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 = 2*sin(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;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/119251303
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)