How to Make an Executable From MATLAB Code

Save

Matlab is a piece of engineering software designed by MathWorks. When you write code in Matlab, you may want to create an executable to run the code as a standalone application outside of your Matlab m-file. Fortunately, Matlab has a feature for doing just that. The Matlab Compiler can create a standalone executable from your Matlab code, which can then run in a runtime engine called Matlab Compiler Runtime (MCR). Once compiled, your standalone application, along with MCR, can be shared with other users for free.

Things You'll Need

  • Matlab R2007 (or later version)
  • Matlab Compiler
  • Open Matlab.

  • Choose the m-file you would like to create into a standalone executable, and note the name of the file. You do not need to open the m-file.

  • Invoke the Matlab Compiler by typing the following into the command window: "mcc -m Filename." "Filename" should be the name of your m-file, including the ".m" extension, such as "program1.m)."

  • Press "Enter." The compiling process can take anywhere from a few seconds to several minutes, depending on the size of the code and the speed of your computer.

Tips & Warnings

  • If Matlab Compiler did not come standard with your version of Matlab, you will need to purchase a license for the Compiler from the MathWorks website.
  • To access your newly created executable, go to your Matlab workspace directory (the one you specified when you installed Matlab). There will be several files with different file extensions and the same name as your m-file. Click on the one with the ".exe" file extension to run the standalone executable.

References

Promoted By Zergnet

Comments

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!