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.