You can compile
code to an executable, so that Matlab isn’t needed to run the
.m file–but the free Matlab Compiler Runtime is needed on the non-Matlab PC.
does not currently have the ability to compile
.m files as Matlab does.
Another way to share
.m code with non-Matlab users is to have them install free GNU Octave, which runs almost all Matlab
.m code that doesn’t use obscure specialized proprietary Matlab toolboxes.
- Matlab Compiler does NOT in general speedup your Matlab code execution.
compiling PC: ensure Matlab Compiler is installed:
- running PC: Install Matlab Compiler Runtime. The MCR must match the Matlab version of the compiling Matlab.
- create test program by saving into a file
function Y = mymcc() X = 0:0.01:2*3.14; Y = sin(X); plot(X,Y) title('Test of MCR') xlabel('x') ylabel('y') disp('I ran an MCR program!') end
.mfile in Matlab:
mcc -m -v mymcc.m
- Run compiled Matlab program without Matlab
I ran an MCR program!
along with a typical Matlab plot window showing a sine wave.
Close the plot window to end the execution of your program.
The Matlab Compiler allows you to compile your existing .m Matlab script to run as an executable on another PC without Matlab.
See the readme.txt created with the mcc command above.