Installing MATLAB on Ubuntu

June 18, 2012

MATLAB (matrix laboratory) is a software developed by MathWorks that allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, Java, and Fortran.

Although a lot of software are designed for OS like Windows, this software has also a version designed for Linux.

The installation is quite easy and one can just follow the instructions described inside the “install_guide.pdf” that can be found in the DVD of Matlab (or you can download it from the source at the end of this post) and if you are lucky you can start working with this software without encountering any errors during the overall process.

I decided to summarise the overall process trying to point out the most important part that could led to error.

1) obviously the first thing to do is insert the DVD inside the DVD drive of your pc. Otherwise if you have a back up copy of the DVD like as a disk image in the format .iso, then you just need to mount it.

2) open your terminal and change the location to the directory of your DVD. For my case it is: cd /media/cdrom1/

3) now we need to launch the installer. To do so you just need to type: ./install or sudo ./install

the secondo version with sudo is to give the permission to the installer to create directory in special directory that requires root privilege.

4) now you just need to follow the instructions that appear to complete the installation.

To start MATLAB software you just need to type in the terminal the path where is located the script-shell type file called “matlab“.

For my case it’s:

/usr/local/MATLAB/R2012a/bin/matlab

In the case you have Ubuntu 11.04 or newer you will notice a message of warning(although the software will open up just fine):

/usr/local/MATLAB/R2011a/bin/util/oscheck.sh: 605: /lib/libc.so.6: not found

Some answer to why there is this warning can be found here (it’s written in Italian). To solve this problem you just need to type this in the terminal:

for 32 bit version of Ubuntu

sudo ln -s /lib/i386-linux-gnu/libc-2.13.so /lib/libc.so.6

for 64 bit version of Ubuntu

sudo ln -s /lib64/x86_64-linux-gnu/libc-2.13.so /lib64/libc.so.6

In my case I noticed that insted of libc-2.13.so I have in my system libc-2.15.so. So I just changed the command up in this:

sudo ln -s /lib/i386-linux-gnu/libc-2.15.so /lib/libc.so.6

—————————————————————————————————————————————————–

UPDATE: I also noticed that, instead of doing the above command, you can just copy the file libc.so.6 that is inside the folder /lib/i386-linux-gnu/ into the required folder that is  /lib  . This method is the same as the above command that is creating a file called libc.so.6 that is linked to the file libc-2.15.so.

—————————————————————————————————————————————————–

Then I just relaunched MATLAB and now the warning has disappeared.

To have a fast access to the program we can create a Launcher inside of our Dash or better put in the sidesibar of Unity.

First we need to get an icon for our Launcher. Just type this inside of your terminal:

sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png

or simply save this image and put it in the directory /usr/share/icons/

then you just need to follow this tutorial.

PS: in the following links you can read about some extra problems and their solutions not indicated in this tutorial because for now it’s not of my interest.

Sources:


How to create custom Launcher for the Dash of Unity

June 16, 2012

When I finally installed a particular program in Ubuntu, I noticed that during the installing process Ubuntu didn’t create a shortcut launcher inside the Dash, let alone inside the sidebar.

The whole process of creating a custom launcher is really simple, all you need to do is to create a simple file with the format .desktop.

To begin you just need to paste the following code inside a text editor like gedit:

[Desktop Entry]
Name=
Comment=
Exec=
Icon=
Terminal=false
Type=Application
Categories=

Name-> refers to the name that will be displayed inside the Dash

Comment-> you can put a comment to describe the use of this launcher or whatever (by this you can guess that this parameter is optional)

Exec-> you need to type the path of the executable program that this launcher will run. Example: /usr/local/Matlab/R2012a/bin/matlab. If the program doesn’t start maybe you can add at the end ot the path the option -desktop. When I have this sort of problem, this solution works just fine. So the path will become this way /usr/share/Matlab/R2012a/bin/matlab -desktop

Icon-> you need to type the path of the icon that this launcher will display. Example: /usr/share/icons/matlab.png

Terminal-> determine if the program need to be run through the terminal or not.

Type-> describe which type is this launcher. It could be Application, Link or Directory

Categories-> indicates in which category the launcher will be put inside the Dash.

After filling up the all parts you just need to save this file in XXX.desktop, where XXX could be whatever name you want.

The last operation is to give this file the permission to run as an executable. To do so you just need to type this inside the terminal:

sudo chmod +x XXX.desktop

This works only if you are inside the same directory of the file .desktop, otherwise you need to change the XXX.desktop with the full path.

you should be able to notice a little difference in the displaying of the file .desktop you just created.

Before the command it was visible in this way

After, it become this way

To make it visible inside the Dash of Unity you just need to move it inside the directory

/usr/share/applications/

or

~/.local/share/applications/

In the second case the launcher will be visible only to the user that created it.

Now that everything is done you can open the Dash and type the name of the launcher you just created and if you did everything okay, you should find it easily.

To add it to the sidebar of Unity, you just need to drag and drop the launcher inside the Dash to the sidebar, just like with any other launcher already inside the Dash.

PS: The file .desktop let you also to create a menu that gives you access to custom shortcuts of the program. However that is not in my interest in this moment so I will not describe it now, but I thought it was useful to point it out.

Source: LauncherFileDesktop



LaTeX: include eps files in pdflatex

June 10, 2012

My problem is I have several image files that are in .eps format.

I need to include these images inside a .tex file and then compile it by pdflatex to create a pdf file.

I already knew that if I compile my .tex file using pdflatex it will give me an error because it doesn’t support .eps graphics but only jpeg, png, pdf…

After some search on the net I found an online solution. In this website you can upload your .eps files and as a result you will have your converted .pdf files to download and to use in your .tex file.

The only disadvantage about this online solution is that if you have a lot of files you need to convert, you will have to stay there to upload one by one because it doesn’t support multiple files.

So the next solution is what I prefer.

You need to declare these two package in your preamble:

\usepackage{graphicx}
\usepackage{epstopdf}

then you can include .eps files as any other simple images:

\includegraphics[option]{file_name}

The trick is that when you are compiling by using pdflatex it will check if the corresponding pdf version of the file exists or not. If it does, it will simply use the pdf version, otherwise it will convert the eps version to a pdf version and then use the pdf file.

NB: To compile the .tex file you need to add “-shell-escape” in your command of pdflatex:

pdflatex -shell-escape name_file.tex

Sources:


									

How to mount an ISO image on Ubuntu

June 10, 2012

An ISO image is an archive file of an optical disc.

In OS such as Windows you can mount it by using software like DAEMON tools lite.

However Ubuntu let you mount it just by typing some simple command on your terminal.

1) First you need to create a directory for your ISO image. To do this open your terminal and write this in it:

sudo mkdir /media/ISO

and then press enter. You will be asked to enter the password for root user.

2) Now is time to mount your disk image by executing this command on terminal:

sudo mount -t iso9660 -o loop /xxx/name_image.iso /media/ISO/

“/xxx/name_image.iso” is the path where is located your disk image.

“/media/ISO/” is the path where you want your disk image to be mounted. In this case it’s the directory that we just created before.

If everything goes well, it will open by itself the directory in which your mounted disk image is, otherwise you can access it like any other directory knowing its path.

To unmount the disk image you just need this command:

sudo umount /media/ISO/

Source:  montare-le-iso-senza-problemi


Customize Grub 2

December 17, 2011

When I install Ubuntu in my computer aside the other OS that I have, it’s always a pain to re-edit the files that control Grub because the way to edit it tend to change with some version of Ubuntu (although they’re small changes, but it’s always a tiresome task to surf the net and find out the little information you need in this vast internet environment) .

So in this article I collect the minimal knowledges about definitions and changes I need to do on this subject to obtain a satisfactory customized Grub.

Since the information I need are written in a perfect way from the sources from where I read them, instead of rearranging the information, I will just copy and paste them here always inside a quotation block. All the credits go to their creators.

GRUB 2 is the default boot loader and manager for Ubuntu since version 9.10 (Karmic Koala).

To determine the version installed in your computer, you can use the line command “grub-install -v” inside the shell of Ubuntu.

To modify GRUB 2, there are some files that need to be considered:

  1. /boot/grub/grub.cfg
  2. /etc/default/grub
  3. /etc/grub.d/  (directory)

/boot/grub/grub.cfg

This file contains the GRUB 2 menu information but the grub.cfg file is not meant to be edited.
Each section is clearly delineated with “(### BEGIN)” and references the script in the /etc/grub.d directory from which the information was generated.
grub.cfg is updated by running the update-grub command as root.

/etc/default/grub

The entries in this file can be edited by a user with administrator (root) privileges and are incorporated into grub.cfg when it is updated.

/etc/grub.d/  (directory)

The scripts in this directory are read during execution of the update-grub command and their instructions are incorporated into /boot/grub/grub.cfg.
The placement of the menu items in the grub.cfg menu is determined by the order in which the files in this directory are run. Files with a leading numeral are executed first, beginning with the lowest number.
Only executable files generate output to grub.cfg during execution of update-grub.
The major default files in this directory used by Ubuntu are:
00_header Sets initial appearance items such as the graphics mode, default selection, timeout, etc.
05_debian_theme The settings in this file set the GRUB 2 background image, text colors, selection highlighting and themes.
10_linux Identifies kernels on the root device for the operating system in use and creates menu entries.
20_memtest86+ Searches for /boot/memtest86+.bin and includes it as an option on the GRUB 2 boot menu.
30_os-prober This script uses os-prober to search for Linux and other operating systems and place the results in the GRUB 2 menu.
40_custom A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the update-grub command.

After editing /etc/default/grub or the scripts in the /etc/grub.d folder the user should run sudo update-grub to incorporate the changes into the GRUB 2 menu.

To modify the aforementioned files you can use the command line “sudo gedit path_of_the_file_to_edit” inside the shell (example: sudo gedit /etc/default/grub). After you input the root password, it will open the software “text editor” with the privilege as root.

In the following lines I will describe only a small part of editing that is of interest to me. To have a more complete editing knowledges you can read the sources at the end of this article from which I collected these information.

First let’s see what’s inside /etc/default/grub (file)

After you opened this file, the entries that are of interest are :

GRUB_DEFAULT – Sets the default menu entry. Entries may be numeric, a complete menuentry quotation, or “saved”
GRUB_DEFAULT=0 Sets the default menu entry by menu position. Counting of entries is the same as in GRUB – the first “menuentry” in grub.cfg is 0, the second is 1, etc.
Note: Grub 1.99 introduces a submenu menu structure. For a menu item in a submenu, the entry becomes a two-digit entry. The first entry is the position of the submenu title in the main menu. The second entry is the position within the submenu. If the submenu is the 3rd entry in the main entry, and the user wishes to boot the first entry in the submenu, it would be designated as “2>0”

GRUB_TIMEOUT=10
Setting this value to -1 will cause the menu to display until the user makes a selection.
The GRUB 2 menu is hidden by default unless another OS is detected by the system. If there is no other OS, this line may be commented out unless the user changes it. To display the menu on each boot, uncomment the line and use a value of 1 or higher.

#GRUB_GFXMODE=640×480
You can remove the # symbol to make this line active. The entry sets the resolution of the graphical menu (the menu text size). It provides resolutions supported by the user’s graphics card (e.g. 640×480, 800×600, 1280×1024, etc). The setting applies only to the boot menu display, not the resolution of the operating system that boots.
Tip: Setting the same resolution in GRUB 2 and the operating system will decrease boot times slightly.
The user can also add multiple resolutions. If GRUB 2 cannot use the first entry, it will try the next setting. Settings are separated by a comma. Example: 1280x1024x16,800x600x24,640×480.
If using a splash image, the resolution setting and the splash image size should be compatible for best results.
Resolutions available to GRUB 2 can be displayed by typing vbeinfo in the GRUB 2 command line. The command line is accessed by typing “c” when the main GRUB 2 menu screen is displayed.

GRUB_DISABLE_LINUX_RECOVERY=true
Uncomment (remove the # symbol) to prevent the “Recovery” mode kernel options from appearing in the menu. If you want a “Recovery” option for only one kernel, make a special entry in /etc/grub/40_custom.

GRUB_BACKGROUND=/path_to_image/filename.   The GRUB 2 splash images are controlled by the GRUB_BACKGROUND variable in ‘/etc/default/grub‘. The image must be a .png, .tga, .jpeg, or .jpg image.

By changing the value about these variables you can create a more suitable menu list of your interest.

After turning up the computer I prefer to see a screen selection with only the lines about the different OS that is installed on my PC and in the order that is better to me.
The easiest way to obtain this result is to create a custom menu entries.

GRUB 2 allows users to create customized menu selections which will be automatically added to the main menu when sudo update-grub is executed. A 40_custom file is available in /etc/grub.d/ for use or to serve as an example to create other custom menus.

The file must be made executable: sudo chmod +x /etc/grub.d/filename. However if you are using the default file 40_custom and not the one you created then this is not necessary.

The easiest way to create the content of a custom menu is to copy a working entry from /boot/grub/grub.cfg. Once copied, the contents of 40_custom can be tailored to the user’s desires. The user can copy existing menuentries from the /boot/grub/grub.cfg file.

The part that is needed looks like this:

menuentry ‘Ubuntu 11.10 – Oneiric Ocelot’ –class ubuntu –class gnu-linux –class gnu –class os {
recordfail
set gfxpayload=$linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos3)’
search –no-floppy –fs-uuid –set=root cb201140-52f8-4449-9a95-749b27b58ce8
linux    /boot/vmlinuz-3.0.0-13-generic-pae root=UUID=cb201140-52f8-4449-9a95-749b27b58ce8 ro   quiet splash vt.handoff=7
initrd    /boot/initrd.img-3.0.0-13-generic-pae
}

or

menuentry “Windows 7 Professional” –class windows –class os {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)’
search –no-floppy –fs-uuid –set=root C406C64E37C181E7
chainloader +1
}

NB: make sure to change the old entry “gfxmode $linux_gfx_mode” in this new one “set gfxpayload=$linux_gfx_mode” otherwise it will give you an error like grub2 – Error: unknown command ‘gfxmode’  on the startup.
 

After you finished modifying the file 40_custom, you just need to remove all but the following files from the /etc/grub.d folder:

  • 00_header,
  • 05_debian_theme,
  • 40_custom
  • and README.

The unnecessary files are:

  • 10_linux
  • 20_linux_xen
  • 20_memtest86+
  • 30_os-prober
  • 41_custom

Alternatively, you may keep other files in the /etc/grub.d folder if you make them unexecutable (which is the way I prefer).

In this case the command needed is sudo chmod -x /etc/grub.d/filename.

Then you just need to run the command update-grub as root to apply the changes!

This is the basic you need to know to modify the list of the boot loader. In the next post I will describe some way to improve the graphic impact of the boot loader

Source: https://help.ubuntu.com/community/Grub2