Compiling Matlab code to run on any PC

  1. ensure Matlab Compiler is installed on compiling PC:

     assert(license('test','compiler')==1)
    
  2. Install the Matlab Compiler Runtime on running PC

Example

Now we write a test program by saving the following test into a file called mymcc.m

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('wow I ran an MCR program!')
end

Then type in Matlab console:

mcc -m -v mymcc.m

creating files:  readme.txt, mymcc, run_mymcc.sh

./run_mymcc.sh mymcc

and you’ll see:

wow I ran an MCR program!

along with a typical Matlab plot window showing a sine wave. Just close the plot window to end the execution of your program.

Notes

The Matlab Compiler allows you to compile your existing .m Matlab script to run as an executable on another PC without Matlab. Note that this is NOT in general a way to speedup your Matlab code execution.

Troubleshooting

See the readme.txt created with the mcc command above.

[Reference:](http://blogs.mathworks.com/loren/2010/11/18/deploying-standalone-applications/

Categories:

Updated:

Leave a Comment