Thursday, August 24, 2006

Matlab and Perl: returning matrixes and cells from Perl to Matlab

Matlab, as one of the most preferable hight level languages among the scientist all over the world, provides interfaces to other programming languages. Normally you can attach to Matlab scripts programs written in: ANSI C, Java SDK , Fortran. This process is called external interfaces and information about it can be found here.

In addition to those languages, there is also possibility to use Perl programs within Matlab scripts. This can attributed to the fact, that Matlab, by default, has embedded Perl interpreter (in fact, it's tripped-down version of the interpreter). Therefor, you can use Perl scripts without any problems.

However, in contrast to ANSI C, Java SDK , Fortran interfaces, Matlab doesn't have any build in routines, to pass and return matrices, cells, vectors to and from Perl. The only thing returned to Matlab is string, which represents stdout of Perl script, meaning, that Matlab receives everything what is returned by print functions in Perl. Everything which normally is printed on stdout, is assigned to one string variable in Matlab. For instance if myscriptInPerl.pl is simple perl script print to console something, then executing this in Matlab console:

A = perl('myscriptInPerl.pl', var1,' var2', var3);

assigns to variable A, all output of myscriptInPerl.pl.

Based on that, my own solution to get matrices, cells, vectors, etc. returned from Perl, is to return string, representing Matlab's code, and executing function eval(A) in Matlab. For example

#myperlscript.pl
#Example file, with Perl scribt to be executed by Patlab
#

$out = "myVector = [2 3 4 5 5 6]; "
#variable with string representing Matlab vector

print $out; #print $out to Matlab

Executing above script in Matlab and evaluating returned string will create myVector variable in Matlab:

A = perl('myscriptInPerl.pl', var1,' var2', var3);
eval(A);

myVector =

2 3 4 5 5 6

Installation of Kubuntu 6.06

Few days ago I was helpping one friend with installation of Kubuntu 6.06 on a PC. I have to admin that personally I would prefer ubuntu, rather then Kubuntu, but he is a fan of KDE environment, so we downloaded it.

I haven't seen Ubuntu yet, so Kubuntu is my first insight into Dapper Drake (DD) family, which has drawn a lot of public attention lately, as being first distribution from Canonical with three and five year support, for desktop and server usage respectively. Since the release, I have read plenty of reviews and opinions about both Ubuntu and Kubuntu. Majority of them was positive about them, and many authors have stayed that (K)Ubuntu is definitively going in the right direction. Due to the fact there is huge amount of available reviews I'm not intending to write one more. Instead, I just want to describe my own experience and feeling about Kubuntu.

To begin with, I need to write that everything went smoothly, and there was not any single problem with installation, even though this PC was more then seven years old.

First positive aspect of Dapper Drake that I noticed is, that the CD you download, both Live and installation CD. Owning to this I could first check if Kubuntu would be working on my PC. I other world's, I could check if Internet connection, printer, etc. was OK. Afterward, knowing that my hardware worked, I started the installation.

Process of installation went smoothly, within surprisingly short time.

After that, I needed to install some additional stuff to my new operating system, so my first thought was to start Synaptic. And I was quite surprised, to find out that there was no Synaptic (graphical package management program for apt). So, no problem, I just run: sudo apt-get install synaptic and there was another surprise - nothing happened. So still, no problem, I open /etc/apt/sources.list and i had to manually unhashed few repositories. Finally, following all those operation I maneged to install what I wanted. Nevertheless, I had and still have mixed feelings about this.

As most of the users I (my friend) wanted to have mp3 support, video codecs, and other popular things, which desktop user must have, and they are not included in (K)Ubuntu by default, on account of licents difficulties. Because of that, I used easyubuntu. This is Python "script that gives the Ubuntu user the most commonly requested apps, codecs, and tweaks that are not found in the base distribution". It worked perfectly, in few minutes I had everything I wanted, and everything was working (audio/video).

Next, I needed to setup printer. I use netwerk HP printer. And there was no surprise, niether. It just worked, after finding it on the list of all printers in configuration panel.

The last stage, was to install VMware server. Unfortunately, this must be done manually, because there are no apt packages. So, I registered (to download vmware you must to register in order to receive free serial number) and I began the installation. There was another nice surprise, everything went perfectly. All process of vmware setup, consists of accepting default parameters :-). That was it:-)

So in conclusion, I strongly feel that Dapper Drake is good or even very good distribution, if you consider only first impression only. However, that little difficulty with Synaptec and apt, can be problem for newbies. I am sure, that my sister, would have huge problems with that, and what's more, I don't see any reasons why it is done like this.

This was my first text about Kubuntu 6.06. I reckon that during further exploitation there will be something new and maybe more interesting to write about.

Gmail and importing mails from other mail account

Some time ago, I switched from my old webmail, to new gmail provided by google.com.

Everything would be perfect if not the fact that gmail, does not have option for importing e-mails form other pop3 servers.

The only solution I found was to download all you emails using e.g. MS Outlook or Evolution. After this, it is necessary to run special program, which will send all your just downloaded mails to gmail account. It isn't the best solution to this problem, but I could not find enythig else.

Fortunetlly, I have access to Linux server with reasonable bandwich, so I downloaded all my mails from former account (more than 600MB) using Evolution mail client. It is client which goes with Gnome as default. Following this, you need to use one of available programs (gExodus - only Windows, gml, ngml) to export you mails from e.g. Evolution to gmail account. Evolution stores all emails in mbox files. If you use Ubuntu Breeze 5.10, this file shoud be somewhere in you home directory.

To export all you emails stored in mbox you can use e.g. gml python script. However, this script wasn't working for me. So, I found modyfied gml (ngml).

Example usage of ngml:

ngml mbox "/home/me/.mail/Inbox/Inbox.mbox" myaccount@gmail.com

And, finally it worked. All those operation were performed on Ubuntu server, which was used, in this case as SMTP server to send all those emails.

Nevertheless, I found it very strange that you have to do so many tricks to import your mails to gmail account. I wander why it is so complicated?