- Home
- User Articles
- How to Talk to ZEMAX from MatLab
- Home
- Programming ZEMAX
- Extensions
- How to Talk to ZEMAX from MatLab
How to Talk to ZEMAX from MatLab
- By Derek Griffith
- Published 3 January 2006
- User Articles , Extensions
-
Rating:




Tracing Large Numbers of Rays
The standard text mode of the DDE call is adequate for many purposes, but not when large amounts of data have to be exchanged between the client and the server. This situation arises when you need to trace a large number of rays.
Instead of tracing the rays one at a time, an array containing a list of all the rays to be traced is created, and then the entire array is passed to ZEMAX at one time. ZEMAX then traces all the rays, and passes the entire array back to the client. Rather than transferring all this data over DDE, a pointer to the location in memory of the array is passed instead. This eliminates the bottlenexck of DDE communication when tracing large numbers of rays.
Unfortunately, at the time of writing the toolbox, Matlab did not allow DDE modes other than text. To circumvent this problem, it was necessary to write some C code in mex (Matlab executable) format. The resulting .dll is called zArrayTrace.
Type help zArrayTrace to get more information on bulk ray tracing. It will also be useful to consult the corresponding section in the ZEMAX manual. To help set up the ray input data for zArrayTrace mode 0, there is a function called genRayDataMode0.