Hi team,
I want to be able to import Zemax ZRD binary files into MATLAB. I tried fopen and fread but had no luck. I see examples of code for reading Zemax ZBF files on the File Exchange but nothing for ZRD files.
Please help.
Hi team,
I want to be able to import Zemax ZRD binary files into MATLAB. I tried fopen and fread but had no luck. I see examples of code for reading Zemax ZBF files on the File Exchange but nothing for ZRD files.
Please help.
Hi Priscilla,
Having written such an importer many years ago, I would not advise you to do it, at least not the way I did. Zemax 22.2 introduced a way to save the ZRD content as text tab separated value files. This makes huge files but the loading is much simpler.
This knowledge base article also offers a solution with the API and a DLL:
If you still think you need to write such importer in Matlab, you may start from the python code below:
A few additional points:
Hi Ray,
Thank you for your advice and support. I have used the sample batch ray reading .m file from the link you provided. I just changed the file name and directories in the code. However, I am getting the errors below; kindly assist on how to correct them.
Hi team,
Kindly assist with the above error; I am stuck so far that MATLAB seems not to understand some methods and functions in this ZRD file reading script. What to do to resolve the matter?
Thank you all.
Prisila.
Hi Priscilla
I ran the MATLAB_ZRDLoaderFull.m file from https://support.zemax.com/hc/en-us/articles/1500005576882-Batch-Processing-of-Ray-Trace-Data-using-ZOS-API-in-MATLAB-or-Python and it worked without any problem. In the code, the dll should be left in the same folder as the Matlab file:
Let us know if this is what you did.
Hi Sandrine,
Thank you for your response. I attempted to use the same files from the link you provided without making any changes. In addition, as shown in the screenshot below, I kept all files in the same folder. However, when the script is run, no result is displayed. I'm working with both 64-bit MATLAB and OpticStudio software. What could be causing this?
Hi
Hi Sandrine,
Thank you for support, I got it fixed.
Hi all!
Thank you for your support; I managed to use the batch ray database processing in Matlab. However, the intensity reading appears to be incorrect, as I expected to see the total intensity in microns based on the trends in the original files. Is there anything done to convert the values, or is there something I am missing at some point in the processing? Note that I used the sample Matlab file provided in the tutorial with some changes to support my own data.
Here is sample of output power!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.