Matlaby Happiness
November 13, 2008
Recently, I found myself doing weird things in Matlab (factored MDPs are to blame): using cell arrays, records, and cell arrays of records containing multidimensional arrays… I was already on the verge of using objects. While technically it is possible to do all this, they open unseen depths of code ugliness. Worse than that(??), they make the code really slow: they seem non-Matlabish not only to the human eye, but also to the Matlab interpreter (more on this in a later post).
All of that factored MDP stuff cries for C++ or Java or any normal programming language I don’t speak. I could see two routes: (1) calling Matlab from C++ or C++ from Matlab. I tried both combinations once, and I will not do that ever again. (2) writing everything in C++/Java, which makes the factored MDP parts ten times easier, and everything else (visualization, debugging, statistics) ten times more difficult. So far, I’ve gone for the third route: writing Matlab code with cell arrays of records containing multidimensional arrays, and swearing a lot.
But today I discovered that I can call Java from Matlab, and they mix very smoothly. I don’t know how it will work out in practice, but seems to be quite user-friendly. Automatic type conversion, my word.
I know, Matlab has Java support for ages. Ironically, when Matlab hangs up, it dumps long Java error messages – if nothing else, that could have given me a clue. I could have looked it up in the help, in the documentation, on google. But I have not. Until now. And now I’m happy.
November 13, 2008 at 8:03 am
Hi! (:
What about Python? I haven’t worked with Python yet, but I’ve heard many good things about it.
It is not a fast programming language (probably in the same order of Matlab), but at least it is a real programming language with a lot of flexibilities (based on what I read/heard). It seems that there are good numerical computation libraries too.
I may try it some day. If I do, I’ll let you know. If you do sooner, please share your experience with us. (:
November 14, 2008 at 5:06 am
Hi,
Yes, I also know a few Python-fans (btw, have you noticed that there are no simple “Python users”, only “Python fans”?). But obviously, they are wrong, and Matlab is THE way to go ;-)
But I agree with you, at some point in life, I’d also like to learn Python. But now that Matlab and Java work together so well, chances are good that I won’t experiment with other options for a while :-)
March 8, 2009 at 3:05 am
Hey Istvan,
I wrote a sweat C++ library for creating dia files. Helps me a lot with visualizations. Let me know if you’re interested.
- John
March 8, 2009 at 3:05 am
sweat = sweet
painful for me to see a misspelling that i can’t correct…