If you have the Matlab compiler, it is possible to compile your Matlab scripts written using the toolbox to standalone extensions that can be run from the ZEMAX Extensions menu. There are a few traps that must be avoided when attempting this.

Firstly, there are a few Matlab functions that cannot be compiled, and you will have to think of workarounds for such functions (fortunately not many).

Secondly, while your standalone extension should run fine on a machine on which Matlab is installed, it will not run on a machine that does not have the Matlab runtime libraries. You must therefore package your extension together with the Matlab runtime libraries to make it fully portable. Mathworks makes this easier by packaging most of the required runtime libraries in a self-extracting archive called mglinstaller.exe (typically found in C:/MATLAB/extern/lib/win32 or thereabouts).

The final trap is that the regular Matlab runtime libraries do not contain the code for the DDE functions mentioned above. These .dll files can be found by searching your Matlab installation for files matching dde*.dll (typically C:/MATLAB/Toolbox/matlab/winfun or thereabouts). The runtime libraries, including the DDE libraries, must be installed to a directory that is on the Windows search path.