✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab完整代码及仿真定制内容点击👇
🔥 内容介绍
该模拟 GUI 用于辅助像差、干涉测量和光学测试的教学。它是为罗切斯特大学光学研究所的课程开发的,专门针对本科水平的 OPT 242 和研究生水平的 OPT 442(仪器光学)。GUI 界面允许用户输入像差/波前系数作为初级赛德尔像差或条纹泽尼克系数。GUI 然后提供各种显示:
波前像差可视化:波前表面图、波前彩色图、波前轮廓线(矢状和切向扇形)横向射线误差可视化:射线截距图、点图成像系统性能:点扩散函数、MTF(2D 彩色图或沿正 fx 和 fy 轴的线条)
干涉测量:单通或双通2光束干涉仪(例如Fizeau、Mach-Zehnder、Twyman-Green干涉仪)、横向剪切干涉仪(剪切板测试)
非干涉测试:Shack-Hartmann 点模拟器、傅科刀口和线测试
📣 部分代码
function ErrCode = OPTx42_simulator()
% GUI developed for the OPT 242 (Aberrations, Interferometry, and Optical
% Testing) class at the University of Rochester. Also used for
% graduate-level OPT 442 (Instrumental Optics) course. The GUI allows the
% user to specify Seidel aberration coefficients for Zernike polynomial
% coefficients for a system with a circular pupil, and allows visualization
% via wavefront maps, ray aberration plots, spot diagrams, MTF plots and
% curves, PSF's, interferograms (2-beam and lateral shearing),
% Shack-Hartmann spots, and knife-edge or wire tests.
%
% Set defaults
h = 0;
PolyType = 1;
SeidelFlag = true; % Added 9/19/2022, Rev. 1.8 (false means Zernikes are used)
v_Seidel = zeros(1,8);
PlotType = 1;
GWmat = zeros(201);
% Create GUI figure window
% set(0, 'Units', 'normalized');
SVfig = figure('Units', 'normalized', 'Position', [0.25, 0.25, 0.4, 0.4],...
'NumberTitle', 'off', 'Tag', 'SVfig');
% Generate input pane
InputPane = uipanel(SVfig, 'Units', 'normalized', 'Position', [0.013, 0.013, 0.31, 0.95],...
'Title', 'Input Panel', 'FontUnits', 'points', 'FontSize', 11,...
'BackgroundColor', [1 1 1]*0.8);
% New "Polynomial type" menu (Seidel vs. Zernike) added 9/19/2022, Rev. 1.8
PolyType_menu = uicontrol(InputPane, 'Style', 'popupmenu', 'String',...
{'Seidel', 'Zernike'}, 'Units', 'normalized',...
'Position', [0.1, 0.92, 0.8, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center',...
'BackgroundColor', [1 1 1]*0.9, 'Callback', @PolyType_callback);
uicontrol(InputPane, 'Style', 'text', 'String', 'h:', 'Units', 'normalized',...
'Position', [0.05, 0.85, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
h_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.83, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @h_input_callback);
W011x_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W011,x (TLT,X):', 'Units', 'normalized',... % Added variable names to labels so that they can be programmatically switched between Seidel and Zernike labels (9/19/2022, Rev. 1.8)
'Position', [0.05, 0.76, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W011x_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.74, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W011x_input_callback);
W011y_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W011,y (TLT,Y):', 'Units', 'normalized',...
'Position', [0.05, 0.68, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W011y_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.66, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W011y_input_callback);
W020_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W020 (DEF):', 'Units', 'normalized',...
'Position', [0.05, 0.6, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W020_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.58, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W020_input_callback);
W040_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W040 (SPH3):', 'Units', 'normalized',...
'Position', [0.05, 0.52, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W040_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.5, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W040_input_callback);
W131_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W131 (CMA3):', 'Units', 'normalized',...
'Position', [0.05, 0.44, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W131_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.42, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W131_input_callback);
W222_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W222 (AST3):', 'Units', 'normalized',...
'Position', [0.05, 0.36, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W222_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.34, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W222_input_callback);
W220_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W220 (FCR3):', 'Units', 'normalized',...
'Position', [0.05, 0.28, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W220_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.26, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W220_input_callback);
W311_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W311 (DST3):', 'Units', 'normalized',...
'Position', [0.05, 0.2, 0.45, 0.033], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
W311_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...
'Position', [0.5, 0.18, 0.45, 0.06], 'FontUnits', 'points',...
'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W311_input_callback);
Units_text = uicontrol(InputPane, 'Style', 'text', 'String', '(W coefficients in units of waves)',...
'Units', 'normalized', 'Position', [0.05, 0.1, 0.95, 0.07], 'FontUnits', 'points',...
'FontSize', 8, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);
UpdateButton = uicontrol(InputPane, 'Style', 'pushbutton', 'String', 'Update', 'Units', 'normalized',...
'Position', [0.166, 0.03, 0.677, 0.08], 'FontUnits', 'points',...
'FontSize', 12, 'FontWeight', 'bold', 'HorizontalAlignment', 'center',...
⛳️ 运行结果
🔗 参考文献
[1]薛瀚宸,童童,张俊武,等.基于Matlab图像处理的光学干涉实验测量研究[J].物理与工程, 2022, 32(5):133-137.