Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: MATLAB hangs with MEX code
Date: Mon, 10 Aug 2009 22:36:18 +0000 (UTC)
Organization: Imperial College London
Lines: 41
Message-ID: <h5q7d2$2u4$1@fred.mathworks.com>
References: <h5puv2$oa2$1@fred.mathworks.com> <342d4053-e7a6-443e-9ed9-a00f427ce172@c34g2000yqi.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1249943778 3012 172.30.248.38 (10 Aug 2009 22:36:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Aug 2009 22:36:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1570235
Xref: news.mathworks.com comp.soft-sys.matlab:562245


Rune Allnor <allnor@tele.ntnu.no> wrote in message <342d4053-e7a6-443e-9ed9-a00f427ce172@c34g2000yqi.googlegroups.com>...
> On 10 Aug, 22:12, "Jose Antonio " <jurig...@gmail.com> wrote:
> > Hi everybody
> >
> > I am trying to make a MEX function to split a double class grey scale image into 2^N areas, which I had already done successfully in MATLAB.
> >
> > The thing is that the compiled function works properly for N up to 8, and then MATLAB simply hangs, and I have to stop the process.
> >
> > I guess I might be again messing up with memory management, but I find no clue how to get things to work. Any help will be very welcome!
> 
> Memory managment is almost certainly not the main
> problem.
> 
> When a program 'hangs' it is usally because some
> control loop does not terminate; you forget to
> increase a counter, you compare to the wrong number,
> or something like that.
> 
> The way to handle these things is to work in a C
> development environment, either on the command line
> or an IDE. You develop and debug the C business code
> in this environment, and then only use the MEX
> routine as an interface to the C code.
> 
> You organize the C code as a number of small functions
> with clear responsibilities. Test each function
> independently, then assemble all of them to the
> main working program.
> 
> The general principle is to divide and conquer.
> 
> Rune


Hi Rune

Nice suggestion! I had not though about improper loop behavior or similar, since the code works fine for N up to 8... But I will check it again :)

Any way that I can make this work with a proper C environment? I mean, my real goal is to get better with Matlab and C as well, so any recommended software or similar would be great!

Jose