Sunday, May 06, 2007

Sprechen C MATLAB

Sprechen Sie MATLAB? This was on an ad-poster by Mathworks that I saw posted on Longin Jan Latecki's office door. No literate can deny how much Computer Science has influenced thinking styles and the pace of research in human quest for knowledge (genomics, bioinformatics, software simulations etc.). MATLAB is one product that has such outstanding influence on many many applied scientific areas (I call applied because I am not sure if MATLAB has led to any purely theoretical insights. By theoretical insights I mean ability to see non-trivial proofs.)

I have used MATLAB for several of my projects. MATLAB is an interpreted language and is known to be slower for 'C-style' programs. But in many cases you need to write blocks of code in 'C-style'. Since MATLAB allows you to interface with C-programs it's worth to know how to write C-programs that you can call in MATLAB without using files as communication (using files again slows down things doesn't it?)

In learning any thing new just don't let "But what if" trouble bother you that much. What if I want to pass pointers, what if I want to pass cell arrays, what if I want to return more than one variable from C etc. Well, you can do all these things but don't worry about all those at once before even getting started, deal one thing at a time. I borrowed this But what if idea from Scott's post about such problem in theoretical perspective which is much more serious! Now let's C how to start building the interface.

The key problem in building any interface is passing around parameters without confusion. The basic anatomy of a typical C-MATLAB file can be seen here. I have simple and clear demonstrations for passing scalars, arrays and structures. The README shows how to use the demos. I recently fixed a memory leak in "kdnn" function of Kd-tree software package for MATLAB written in C by Guy Shecther. You can download the "kdnn" function from here after downloading the original package. kdnn finds k nearest neighbors for a given d dimensional point.


Bilal said...


Is there a version of kdnn, where I can add items to the tree after it is built without rebuilding it from scratch??

Unknown said...

Sorry Bilal, I don't have that version. I would recommend to contact Guy.

Anonymous said...


I mostly visits this website[url=].[/url]You have really contiributed very good info here Do you pay attention towards your health?. Let me show you one truth. Recent Scientific Research indicates that closely 80% of all United States adults are either fat or weighty[url=].[/url] Hence if you're one of these people, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? [url=]Quick weight loss[/url] is not like piece of cake. You need to improve some of you daily habbits to achive weight loss in short span of time.

About me: I am webmaster of [url=]Quick weight loss tips[/url]. I am also health trainer who can help you lose weight quickly. If you do not want to go under hard training program than you may also try [url=]Acai Berry[/url] or [url=]Colon Cleansing[/url] for effective weight loss.

Anonymous said...

I've been exploring for a little for any high-quality articles or weblog posts on this kind of house . Exploring in Yahoo I eventually stumbled upon this site. Studying this info So i am happy to show that I've a very excellent uncanny feeling I found
out exactly what I needed. I so much unquestionably will make sure to
do not disregard this site and provides it a look regularly.

Look at my web page