Read ZEMAX Beam File (ZBF)
Updated 22 Jul 2011
ZEMAX is an optical simulation code (http://www.zemax.com/). One of its features, Physical Optics Propagation, calculates the electric fields as they travel through the simulated optical system. The results can be saved in the ZEMAX Beam File (ZBF) format. It is useful to be able to read the ZBF file into Matlab so the electric field amplitudes and phases can be plotted in Matlab for display. Multiple simulation results can be easily compared in this way.
Since this code uses mex, the user will first need to compile part of the code. I only tested this on Windows, and I believe the code will only compile using gcc. Please install MinGW (http://www.mingw.org/) and GNUMex (http://gnumex.sourceforge.net/). Then, go to Matlab and type:
This will compile the mex part of the code. To run the code, type
[ x y Ex Ey ] = read_zbf( filename )
and replace filename with a string containing the filename of the ZBF file to be read. To plot the results, issue commands like:
pcolor(x,y,real(Ex)); shading flat
to plot just the real part of the x-component of the E-field amplitude in the ZBF file.
I am grateful to Bill Jones for sending me his make_zbf C-code which I modified to make this code. I believe both of our codes are based on an example file included in ZEMAX.
Sean Bryan (2023). Read ZEMAX Beam File (ZBF) (https://www.mathworks.com/matlabcentral/fileexchange/32099-read-zemax-beam-file-zbf), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired: Read a binary ZEMAX beam file (ZBF)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.