?About the author: A Matlab simulation developer who loves scientific research. He cultivates his mind and improves his technology simultaneously. For cooperation on MATLAB projects, please send a private message.
Personal homepage: Matlab Research Studio
Personal credo: Investigate things to gain knowledge.
For more complete Matlab code and simulation customization content, click
Intelligent optimization algorithm Neural network prediction Radar communication Wireless sensor Power system
Signal processing Image processing Path planning Cellular automaton Drone
Content introduction
This simulation GUI is used to assist in the teaching of aberrations, interferometry, and optical testing. It was developed for courses in the Institute of Optics at the University of Rochester specifically for OPT 242 at the undergraduate level and OPT 442 (Instrumental Optics) at the graduate level. The GUI interface allows the user to enter aberration/wavefront coefficients as primary Seidel aberrations or fringe Zernike coefficients. The GUI then provides various displays:
Wavefront aberration visualization: wavefront surface plot, wavefront color plot, wavefront contour (sagittal and tangential sector) Transverse ray error visualization: ray intercept plot, point plot Imaging system performance: point spread function, MTF ( 2D color plot or lines along the positive fx and fy axes)
Interferometry: single or double pass 2-beam interferometer (e.g. Fizeau, Mach-Zehnder, Twyman-Green interferometer), transverse shear interferometer (shear plate test)
Non-interference testing: Shack-Hartmann point simulator, Foucault knife edge and line testing
Part of the code
function ErrCode = OPTx42_simulator()</code><code>?</code><code>?</code><code>% GUI developed for the OPT 242 (Aberrations, Interferometry, and Optical</code> <code>% Testing) class at the University of Rochester. Also used for</code><code>% graduate-level OPT 442 (Instrumental Optics) course. The GUI allows the</code><code>% user to specify Seidel aberration coefficients for Zernike polynomial</code><code>% coefficients for a system with a circular pupil, and allows visualization</code><code>% via wavefront maps, ray aberration plots, spot diagrams, MTF plots and</code><code>% code><code>% curves, PSF's, interferograms (2-beam and lateral shearing),</code><code>% Shack-Hartmann spots, and knife-edge or wire tests.</code><code>%</code><code>?</code><code>?</code><code>% Set defaults</code><code>h = 0;</code><code>PolyType = 1; </code><code>SeidelFlag = true; % Added 9/19/2022, Rev. 1.8 (false means Zernikes are used)</code><code>v_Seidel = zeros(1,8);</code><code>PlotType = 1;</code><code>GWmat = zeros(201);</code><code>?</code><code>% Create GUI figure window</code><code>% set( 0, 'Units', 'normalized');</code><code>SVfig = figure('Units', 'normalized', 'Position', [0.25, 0.25, 0.4 , 0.4],...</code><code> 'NumberTitle', 'off', 'Tag', 'SVfig');</code><code> </code> <code>% Generate input pane</code><code>InputPane = uipanel(SVfig, 'Units', 'normalized', 'Position', [0.013, 0.013, 0.31, 0.95],.. .</code><code> 'Title', 'Input Panel', 'FontUnits', 'points', 'FontSize', 11,...</code><code> 'BackgroundColor', [1 1 1]*0.8);</code><code>?</code><code>% New "Polynomial type" menu (Seidel vs. Zernike) added 9/19 /2022, Rev. 1.8</code><code>PolyType_menu = uicontrol(InputPane, 'Style', 'popupmenu', 'String',...</code><code> {' Seidel', 'Zernike'}, 'Units', 'normalized',...</code><code> 'Position', [0.1, 0.92, 0.8, 0.06], \ 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center',...</code><code> 'BackgroundColor', [1 1 1]*0.9, 'Callback', @PolyType_callback);</code><code>?</code><code>uicontrol(InputPane, 'Style', 'text', 'String', 'h:', 'Units', 'normalized',...</code><code> 'Position', [0.05, 0.85, 0.45, 0.033], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', \ 'BackgroundColor', [1 1 1]*0.8);</code><code>h_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0' , 'Units', 'normalized',...</code><code> 'Position', [0.5, 0.83, 0.45, 0.06], 'FontUnits', 'points' ,...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @h_input_callback);</code><code>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)</code><code> 'Position', [0.05, 0.76, 0.45, 0.033], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor' , [1 1 1]*0.8);</code><code>W011x_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units ', 'normalized',...</code><code> 'Position', [0.5, 0.74, 0.45, 0.06], 'FontUnits', 'points',... </code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W011x_input_callback);</code><code>W011y_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W011,y (TLT,Y):', 'Units', 'normalized',...</code><code> 'Position', [0.05, 0.68, 0.45, 0.033], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);</code><code>W011y_input = uicontrol(InputPane, 'Style', 'edit\ ', 'String', '0', 'Units', 'normalized',...</code><code> 'Position', [0.5, 0.66, 0.45, 0.06 ], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W011y_input_callback);</code><code>W020_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W020 (DEF):', 'Units' , 'normalized',...</code><code> 'Position', [0.05, 0.6, 0.45, 0.033], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);</code><code>W020_input = uicontrol (InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...</code><code> \ 'Position', [0.5, 0.58, 0.45, 0.06], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment' , 'center', 'Callback', @W020_input_callback);</code><code>W040_label = uicontrol(InputPane, 'Style', 'text', 'String', ' W040 (SPH3):', 'Units', 'normalized',...</code><code> 'Position', [0.05, 0.52, 0.45, 0.033], 'FontUnits\ ', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]* 0.8);</code><code>W040_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized\ ',...</code><code> 'Position', [0.5, 0.5, 0.45, 0.06], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W040_input_callback);</code><code>W131_label = uicontrol(InputPane, 'Style', \ 'text', 'String', 'W131 (CMA3):', 'Units', 'normalized',...</code><code> 'Position', [ 0.05, 0.44, 0.45, 0.033], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left' , 'BackgroundColor', [1 1 1]*0.8);</code><code>W131_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0 ', 'Units', 'normalized',...</code><code> 'Position', [0.5, 0.42, 0.45, 0.06], 'FontUnits', 'points ',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W131_input_callback);</code><code> W222_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W222 (AST3):', 'Units', 'normalized',...</code><code> 'Position', [0.05, 0.36, 0.45, 0.033], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);</code><code>W222_input = uicontrol(InputPane, 'Style', ' edit', 'String', '0', 'Units', 'normalized',...</code><code> 'Position', [0.5, 0.34, 0.45 , 0.06], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback\ ', @W222_input_callback);</code><code>W220_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W220 (FCR3):', 'Units ', 'normalized',...</code><code> 'Position', [0.05, 0.28, 0.45, 0.033], 'FontUnits', 'points',... </code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);</code><code>W220_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', 'normalized',...</code><code> 'Position', [0.5, 0.26, 0.45, 0.06], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment ', 'center', 'Callback', @W220_input_callback);</code><code>W311_label = uicontrol(InputPane, 'Style', 'text', 'String', 'W311 (DST3):', 'Units', 'normalized',...</code><code> 'Position', [0.05, 0.2, 0.45, 0.033], ' FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1 ]*0.8);</code><code>W311_input = uicontrol(InputPane, 'Style', 'edit', 'String', '0', 'Units', ' normalized',...</code><code> 'Position', [0.5, 0.18, 0.45, 0.06], 'FontUnits', 'points',...</code><code> 'FontSize', 10, 'HorizontalAlignment', 'center', 'Callback', @W311_input_callback);</code><code>Units_text = uicontrol(InputPane, 'Style' , 'text', 'String', '(W coefficients in units of waves)',...</code><code> 'Units', 'normalized', ' Position', [0.05, 0.1, 0.95, 0.07], 'FontUnits', 'points',...</code><code> 'FontSize', 8, 'HorizontalAlignment', 'left', 'BackgroundColor', [1 1 1]*0.8);</code><code>UpdateButton = uicontrol(InputPane, 'Style', 'pushbutton', 'String\ ', 'Update', 'Units', 'normalized',...</code><code> 'Position', [0.166, 0.03, 0.677, 0.08], 'FontUnits\ ', 'points',...</code><code> 'FontSize', 12, 'FontWeight', 'bold', 'HorizontalAlignment', 'center', ...
Operation results
References
[1] Xue Hanchen, Tong Tong, Zhang Junwu, et al. Research on optical interference experimental measurement based on Matlab image processing [J]. Physics and Engineering, 2022, 32(5):133-137.?