How to compile a matlab program?

268 views (last 30 days)
Hello,
I have done a matlab program. Now I want to use it in a matlab free environment (Independent of Matlab)in any computer. Is there anybody who can help me in doing compilation?
Thanks in advance

Accepted Answer

Walter Roberson
Walter Roberson on 6 Mar 2011
You need the Matlab Compiler Toolkit . Information about how to use it is available here
Please note that the Matlab Compiler can only produce executables suitable for the platform (Windows, OS-X, Linux) that the compiler was used on, not on "any computer".
Also please note that running the executable requires installing MCR (Matlab Component Runtime) on the system that is to run the executable, and that you as creater of the executable would be responsible for providing MCR to each of the users -- MCR is not available for downloading from Mathworks. You would also be responsible for ensuring that only people authorized to use your executable get MCR from you: it is not allowed to make MCR available outside your organization without access controls to prevent the public from downloading MCR.
  3 Comments
Angelo Sajeva
Angelo Sajeva on 5 Sep 2023
I am not satisfied by this answer
Walter Roberson
Walter Roberson on 5 Sep 2023
In the time since the above answer was written in early 2011:
  • Mathworks introduced MATLAB Coder (about a month after my posting). MATLAB Coder can compile some portions of MATLAB to C or C++ code
  • At some point, Mathworks was able to start making MCR (MATLAB Component Runtime) available for download instead of making it the responsibility of the program compiler to provide it. This did not, however, apply retroactively; for sufficiently old releases there are still license limitations
  • With some work, it became possible (but not straight forward) to install a Linux subsystem for Windows, and use that in combination with MATLAB executing on Windows to generate executables to run on Linux. This is not supported, and might be tricky to set up, but it does reduce the strict operating system limitations I noted
However, if your dissatisfaction has to do with the fact that it is nessary to pay for an optional product to do this... sorry, but that is something that is not likely to change for the forseeable future.

Sign in to comment.

More Answers (2)

Britech S.A
Britech S.A on 14 Feb 2023
We are now in 2023...we still need to purchase this add-on "Matlab Compiler Toolkit " ?
In the latest version, we can use the program/command "mcc" for building and packaging MATLAB code for deployment ...
Do we still have additional costs to use a MATLAB code in an environment without having to purchase more licenses?
We would like to have a development environment ( with a licensed MatLab installed) from which we have the ability to generate "packages" to run in another environment ( Windows Server ) without having to buy another license...
Is it possible?
Using "mcc" we resolve all this issues?
  1 Comment
Walter Roberson
Walter Roberson on 5 Sep 2023
To compile a MATLAB program, there are a few options:
  • MATLAB Compiler -- produces executables that require MATLAB Component Runtime, most language components are handled, but some toolboxes are not handled at all (such as Symbolic Toolbox)
  • MATLAB Coder -- produces C or C++ code for compiling, fewer language components are supported, graphics are not supported, fewer toolboxes supported, may require modifying code to make it clearer about what array sizes and types are involved
  • Simulink models can be deployed to some hardware targets such as Arduino at no extra cost. This will not support MATLAB in general.
  • more advanced deployment to other hardware might require Embedded Coder
"Do we still have additional costs to use a MATLAB code in an environment without having to purchase more licenses?
YES.
You should probably discuss your needs with the Sales office; for example your might have a situation where MATLAB Production Server would be called for.

Sign in to comment.


Paulo Silva
Paulo Silva on 6 Mar 2011
deploytool

Categories

Find more on Get Started with MATLAB Compiler SDK in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!