Search code examples
matlabcompilationexe

Is it possible to compile Matlab code into a stand alone exe?


Is it possible to compile Matlab code into a stand alone exe? meaning being able to run the program without having to have matlab or the matlab runtime environment installed on the computer?

does it help that the code has no GUI and does not use any toolboxes? also, the only interaction the person has with the code is through the command prompt


Solution

  • You need MATLAB Coder to generate C/C++ code from your MATLAB code. Yes, it does help that you don't have any GUI. Your code also needs to be restricted to the subset of MATLAB language that is supported by code generation. As far as toolboxes are concerned, there are quite a few which are supported by code generation.

    A few people have mentioned the MATLAB Compiler. This is indeed for deployment on a machine where the end user does not have MATLAB, but it does require the installation of the runtime environment (MCR or MATLAB Component Runtime), which is freely distributable if you have a license of MATLAB Compiler. This does allow you to compile GUIs, but anything that is compiled on Windows can only be deployed on Windows, Linux on Linux, etc... (unless things have changed since I last used it).