LoginSignup
0
0

More than 5 years have passed since last update.

Matlab Wars 1.0

Last updated at Posted at 2015-09-11

Note: I'm writing this after a seven-hour fight working in MATLAB, so expect some heavy level indirection. Maybe I will write something much serious later, when I have the time.

So I'm very much obliged to document my own efforts at grappling a research problem (I'm writing a program for image reconstruction) using the most popular scientific language on earth.

Matlab.

Sorry, wrong icon.

matlab.png

But anyway, what's the difference between the tool of the devil and a language that looks like it has been spliced from a dialect of BASIC and some forsaken offspring of Java?

Anyway, back to the topic. The problem I was given to solve was simple. I was supposed to find circular rings, of arbitary radius, in a single color background. Sounds easy? That probably because it is.

Detecting circles in an image, from the Matlab blog.

The function, imfindcircles is the Matlab answer to use the Hough Transform to search for circles. The basic idea is that the transform votes for the pixels that show the highest probability of being part of a circle.

My predecessor used a similar method that searched for circles (he reimplemented the transform, without the voting, and using inline functions), but unfortunately his code only worked cases where the circles has no overlapping surfaces, and only on a single circle. Since the image I'm provided would contain overlapping surfaces and multiple circles, the 53-line code was not really useful.

However, due to the voting process, like all voting processes, there is a margin of error. Somehow, the function would need to search within a range of 25% of the minimum radius to actually get the accurate circle, so that was interesting.

This took me around half an hour to validate, using around three test cases. If you want to ask why, blame the startup time of the JVM, and also Matlab's poor command-line options.

I used Sublime Text 3 to edit my matlab code to alleviate some of the headaches I was having while trying to make the program work but apparently each time I ran the code, a "no desktop" command line prompt popped up, for no use whatsoever.

Michael Katz, I hope you understand what the rest of the world means by "nodesktop". Go help yourself and take a look at how Python or Clojure did it, without forcing people to use the default GUI IDE.

Matlab was supposed to be a REPL-cycle based scripting language, but somehow it was more of a compile-run-test-recompile cycle, without even the speed of a compiled language.

I miss D.

However, due to the fact that all science faculties in Singapore teach the language to undergraduates, without teaching them the basics of computing beforehand, or even introduce a saner language to them (Python, Numpy, Scipy anyone?), the best I know is the usage of Perl in Bioinformatics (Note, not Perl6, but Perl<=5.0), so I have to use Matlab.

Not that I'm complaining...a lot...though. The libraries are nice.

Yup, the libraries are nice. There's nothing I can say about the data structures though. That just gave me a nightmare. Matlab's native data structures could best be described as a monster (actually, several) plastered onto BASIC arrays.

Don't expect anything from your previous computing training to work in Matlab, here be dragons, and they said so, with the price, which was something I also have to say about.

The price of using the matlab compiler is extremely expensive for a hobby project. $49 for a student price? What the heck? With that abdomination of a language?

I may have to use MATLAB now, but given the chance to switch, I would happily do so.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0