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 run_mymatlabfile.sh

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
    addpath('path1...');
end

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);
end

Bash script to run in clusters

#!/bin/bash

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

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

Convert EPS to PDF: problem of bounding box

June 17, 2009

When you save a multiple plots/subfigures figure as an eps file in matlab, the bounding box might not be properly defined. People who use pdflatex need to convert EPS to PDF. The undefined bounding box will cause problems if you use epstopdf to convert EPS to PDF. This problem is shown in the first row in the picture below. The top-left figure is the eps file without properly defined bounding box. Because of this, epstopdf simply printed a letter size pdf file that only contains part of the figure as shown in the top-right figure. You can try to use the option –exact

epstopdf --exact bad.eps

It will probably generate an warning msg like “Warning: BoundingBox not found!” and the resulting pdf is still wrong. One way to fix this problem is to use epstool

epstool --copy --bbox bad.eps --output good.eps

The bbox option tells epstool to generate a (correct) bounding box for the eps file. With a correctly defined bounding box, you can easily convert an eps file to a pdf file.

epstopdf --exact good.eps

The results are shown in the 2nd row of the picture below. epstopdf generated an pdf file in the same size as the eps file.
pic


Install flash player for firefox in ubuntu 8.04

February 1, 2009

1. Open firefox. Go to youtube.com and select any video. If you havn’t install flah, a message of “Hello, you either have JavaScript turned off or an ol version of Adobe’s Flash Player. Get the lastest Flash player.”. Click on the link and you will be redirected to adobe website to download it. Select .deb for Ubuntu x.xx.

2. Let the Package installer software install it. Restart firefox and it should be working.

If it’s still not working, follow the following steps.

3. Open Terminal and input
$> firefox &
to execute firefox.

4. Go to youtube.com and click on any video. It will be just like step 1 but this time you can see the error message from the Terminal. For me, the error messages say
LoadPlugin: failed to initialize shared library /usr/lib/adobe-flashplugin/libflashplayer.so [libnss3.so: cannot open shared object file: No such file or directory]
The problem is not in flash player but because of a dependency lib of flash player mssing .

5. Open Synaptic package manager (System >> Administration >> Synaptic package manager) and install the missing lib (libnss3). Restart firefox and the flash should work fine.


WebDAV client with encrypted SSL connection in ubuntu

January 27, 2009

WebDAV is a set of extensions to the HTTP protocol that allow users to edit and manage files on remote www servers. Here is the installation guide.

1. #> sudo apt-get install davfs2

2. create a folder
mkdir /media/webdav

3. Mount remote webdav server by
sudo mount -t davfs https://ip_address:port /media/webdav



Using rdesktop to remotely access window XP from ubuntu/linux

August 16, 2008

First, install rdesktop if you don’t already have it. rdesktop is a client software for RDP (remote desktop protocol) which is used in various microsoft OS’s.

$ sudo apt-get install rdesktop

Open a terminal and input

$ rdesktop -f -a 16 <ip/domain name>

where -f is for full screen mode and -a is the connection color depth. -a 16 means 16 bits color depth will be used for this connection. These are the two option I used. Other two useful options are -u <username> and -p <password>.

Press Ctrl-Alt-Enter to switch between full screen and window mode.


Restore corrupted (grub) MBR using a live UBUNTU CD

February 27, 2008

I have both ubuntu and windows XP installed in my thinkpad X61. The mbr on my laptop was erased after executing the System Update under windows XP this afternoon. 😦 The grub menu was gone with only four letters – GRUB – appeared on screen after rebooting. The mbr might also be destroyed when you reinstall windows XP. This article will help you to resotre your original mbr using ubuntu live CD.

Here is a way to restore the grub mbr if you have grub previously installed. Read the rest of this entry »


Krusader – Linux ftp/sftp/scp GUI

February 24, 2008

Always has to google it when using SCP terminal command?

Krusader is a very powerful commander style GUI file manager for KDE and many other desktop managers such as GNOME. To install Krusader under ubuntu gusty, type
$> sudo apt-get install krusader

Read the rest of this entry »