Compiling and running standalone matlab executable.

August 21, 2012

First, define the paths:

export LD_LIBRARY_PATH=/opt/matlab2012a/bin/glnxa64:/opt/matlab2012a/sys/os/glnxa64:/opt/matlab2012a/runtime/glnxa64/

Compile the .m file

mcc -mv mymatlabfile.m

The matlab compiler generates two execute files: mymatlabfile and

Ignore the shell script generated by matlab. Simply execute ./mymatlabfile 

If you have addpath commands in your .m file, these will cause error while running the standalone executables. To solve this, do the following

if ~isdeployed

If your .m file has input parameters, execute the file in the following way

mymatlabfile para1 para2.

For example, if this is your matlab file

function myprog(num1, num2)

you call the file by

myprog 100 200

Note that the paramters 100 and 200 will be passed as string instead of numbers so you have to modify your .m file:

function myprog(num1, num2)
if isdeployed
    num1 = str2double(num1);
    num2 = str2double(num2);

Bash script to run in clusters


# total number = 8677
for i in {1..8599..860}
    let j=$i+860-1
    echo "Running $i and $j....."
    srun -c 5 -o output/output$i.txt ./calc_bg_pooling $i $j &

echo "Running the last small part....."
srun -c 5 -o output/output8601.txt ./calc_bg_pooling 8601 8677 &

Create iPhone ringtone for FREE using iTune 8

February 21, 2009

iTune allow users to create their own ringtone from the music file downloaded via iTune store. It’s very convenient for users to create ringtones from their favorite songs  but it’s not free. This guide will show you how to convert mp3/acc files to iPhone for FREE simply using iTune 8. Read the rest of this entry »

CGAL Installation guide

February 21, 2008

For Linux (ubuntu)

  1. Install boost. Go to to check the newest version available. The newest version as of feb,2008 is 1.34.1.
  2. Open a terminal and input
    sudo apt-get install libboost.*-dev libboost-doc libboost.*1.34.1
  3. Boost is installed in a standard location and should be found by CGAL installation program automatically.
  4. Download latest CGAL from this link.
  5. Decompress the downloaded file by inputting
    sudo tar xfv CGAL-3.3.1.tar.gz
  6. Go to the directory CGAL-3.3.1 and input ./install_cgal -i. -i for interactive mode.
  7. Input T for testing the setup. After the testing, the boost you just installed should appear on the the support for menu.
  8. Type B to build the CGAL library. If you h sudo apt-get install libmpfr-devave error message, like “Compilation of libCGAL static failed”, check the install.log file. That is probably due to the missing of MPFR or GMP. Below are the commands to install them respectively.
    sudo apt-get install libgmp3-dev

    sudo apt-get install libmpfr-dev

    After you install MPFR or GMP, go to the main menu and input S -> 7 or 5 -> 0 to auto find the library. If library is installed correctly, it should appear on the the support for: on the main menu along with other library like BOOST.
  9. If you prefer to install CGAL into other directory, Press I and then D to change the installation directory to any director you want, for example, /usr/local/CGAL. Then press I again to let the installer to copy all include/lib/exe files to the designated directory.
  10. If you have problem creating directory in step 9. Just exit the installer and input the command
    ./install_cgal –prefix /usr/local/CGAL -i.
    Then under the main men, press I and install root directory defined by the –prefix parameter should be changed to /usr/local/CGAL. You don’t need to press D to change the install root directory again. Simply press I, the installer should work fine and all required files will be copied to the designated directory.
  11. DONE! 🙂

Math equation in

February 20, 2008

WordPress supports LATEX inline math mode. See WP FAQ for details. LATEX cheat sheet is available at here.
Taylor series:


Santa Rosa screams

February 19, 2008

The high pitch noise from some of the Santa-Rosa CPU are a result of CPU switching from C4 state to other states. If you have the option of switching entering C4 state off in BIOS of you laptop, you might want to consider that. Unfortunately, there is no such option in my thinkpad X61 laptop. Instead I used RMClock to prevent CPU entering C4 state. I set up mine according to this article. The high pitch noise hardly happened after that. Will test on battery life later. 🙂

Fully utilizing the 4th GB memory under 32bit windows OS

February 19, 2008

Theoretically, 32bits windows XP (Vista) should be able to support 4GB memory. However, for some reason M$ only allows 3GB memory under windows XP after sp2. Here is a way to fully utilize the other unsupported 1GB memory in your computer.

1. Download Gavotte Ramdisk at here or here and decompress it any folder you want.

2. Double click ram4g.reg.

3. Execute ramdisk.exe. Select data size to 1GB and media type to fixed media. Click OK and restart your computer. You should be able to see an extra drive in “My computer”.

4. If you want to use this drive as virtual memory, it’s better to enable compression. To do this, simply right click on the drive and select “Format” from the pop-up menu. Select “enable compression” from the pop-up dialog.

5. Another application is using this drive as your browser cache.