Monday, May 12, 2014
From KD: 10 Point Agenda for the next Prime Minister of Ind...
From KD: 10 Point Agenda for the next Prime Minister of Ind...: Honourable New Prime Minister of India, I am writing this a few days before you will take the oath of the office. You ...
Wednesday, May 7, 2014
Michael Hirsch's Blog Post on Compiling Matlab code to run on any PC
Compiling Matlab code to run on any PC
August 8, 2013 at 13:01
The Matlab Compiler allows you to compile your existing .m Matlab
script to run as an executable–e.g. on another PC that doesn’t have
Matlab installed. Typically you will compile for the same operating
system as you have on your Matlab PC (it might be possible to
cross-compile, but I have NOT checked this). You can also output code
suitable for compilation in another compiler–I’ll leave it to you to
read the mcc documentation for now.
There are two caveats:
1) You must have a Matlab Compiler license on the PC you’re using for Matlab–check this by typing in Matlab:
which must return a 1. If it’s 0, you don’t the Compiler license (you or your institution would have to buy a license)
2) The computer where you intend to run the compiled program must have the no-cost Matlab Compiler Runtime (MCR) installed–else you’ll get errors like:
Well, that’s the error I get in Linux.
To install the Matlab Compiler Runtime (do this on your Matlab PC as well as obviously the PC where you want to run the compiled Matlab code, go to this website:
http://www.mathworks.com/products/compiler/mcr/
On Linux, just before finishing the installation you will be told to set environment variables
So before running your MCR program, first run ./matlabvariables, which sets the appropriate variables when you need them on the PC you’re running the MCR code on.
Note: don’t just paste the export statements into .bashrc, because they can interfere with other programs such as nmap–just use them when needed.
————-
Now we write a test program by saving the following test into a file called MyMCC.m
Then type in Matlab console:
When that completes, open Terminal and in your MyMcc.m directory you’ll see an executable file MyMCC.
Type in Terminal
along with a typical Matlab plot window showing a sine wave. Just close the plot window to end the execution of your program.
Reference:
http://blogs.mathworks.com/loren/2010/11/18/deploying-standalone-applications/
There are two caveats:
1) You must have a Matlab Compiler license on the PC you’re using for Matlab–check this by typing in Matlab:
license('test','compiler')
which must return a 1. If it’s 0, you don’t the Compiler license (you or your institution would have to buy a license)
2) The computer where you intend to run the compiled program must have the no-cost Matlab Compiler Runtime (MCR) installed–else you’ll get errors like:
error while loading shared libraries: libmwlaunchermain.so: cannot open shared object file: No such file or directory
Well, that’s the error I get in Linux.
To install the Matlab Compiler Runtime (do this on your Matlab PC as well as obviously the PC where you want to run the compiled Matlab code, go to this website:
http://www.mathworks.com/products/compiler/mcr/
On Linux, just before finishing the installation you will be told to set environment variables
LD_LIBRARY_PATH
and XAPPLRESDIR
with a long string of text. Here’s how to do that- gedit matlabvariables
- copy and paste the text into an export command like this:
## Matlab compiler Runtime (MCR)
export LD_LIBRARY_PATH=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/runtime/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/bin/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/os/glnxa64:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/sys/java/jre/glnxa64/jre/lib/amd64:$LD_LIBRARY_PATHexport XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/X11/app-defaults
- chmod +x matlabvariables
So before running your MCR program, first run ./matlabvariables, which sets the appropriate variables when you need them on the PC you’re running the MCR code on.
Note: don’t just paste the export statements into .bashrc, because they can interfere with other programs such as nmap–just use them when needed.
————-
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')
display('wow I ran an MCR program!')
end
Then type in Matlab console:
mcc -m -v -w enable -R -startmsg -R -completemsg MyMCC.m
When that completes, open Terminal and in your MyMcc.m directory you’ll see an executable file MyMCC.
Type in Terminal
./MyMCC
and you’ll see:
./mcctest
Initializing MATLAB Compiler Runtime version 8.1
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.
Reference:
http://blogs.mathworks.com/loren/2010/11/18/deploying-standalone-applications/
Monday, April 21, 2014
Applied Mathematics
"There is no branch of mathematics, however abstract, which may not some day be applied to phenomena of the real world."
-Nikolai Lobachevsky
-Nikolai Lobachevsky
Thursday, January 9, 2014
wxBanker on Mac OS X 10.9.1
It took a lot of trial and error getting wxBanker set up on the latest Mac OSX. Here's the sequence of steps that worked for me:
1. Download the source from github.
2. Download the dmg for wxPython 2.8 from sourceforge.
3. Run the uninstaller script first to remove wxPython 2.9.*
4. Run the package installer for wxPython 2.8.
5. Run arch -i386 python2.7 main.py
1. Download the source from github.
2. Download the dmg for wxPython 2.8 from sourceforge.
3. Run the uninstaller script first to remove wxPython 2.9.*
4. Run the package installer for wxPython 2.8.
5. Run arch -i386 python2.7 main.py
If you don't use the older version of wxPython, you will see an assertion failure in DoInsert() in the wxPython source.
If you don't run Python using arch it will default to the 64-bit version of Python, which wxPython2.8 doesn't like.
Finally, to sync your database using Dropbox, just remove any existing bank.db file and create a symlink:
ln -s ~/Dropbox/bank.db ~/.local/ share/wxbanker/ bank.db
*A better way is to edit the source and use wxversion to select the older version of wxPython. That way it is not necessary to uinstall the newer version.
If you don't run Python using arch it will default to the 64-bit version of Python, which wxPython2.8 doesn't like.
Finally, to sync your database using Dropbox, just remove any existing bank.db file and create a symlink:
ln -s ~/Dropbox/bank.db ~/.local/
*A better way is to edit the source and use wxversion to select the older version of wxPython. That way it is not necessary to uinstall the newer version.
Subscribe to:
Posts (Atom)