Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: dynamically creating for loops
Date: Wed, 9 Sep 2009 09:18:05 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 12
Message-ID: <h87rsc$8kq$1@fred.mathworks.com>
References: <h87hf1$q8e$1@fred.mathworks.com> <h87qms$a3o$1@fred.mathworks.com> <h87r7o$jub$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252487885 8858 172.30.248.37 (9 Sep 2009 09:18:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 9 Sep 2009 09:18:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:569191


"qooroo " <qoorooAT@gmailDOT.comREMOVECAPS> wrote in message <h87r7o$jub$1@fred.mathworks.com>...
> of course if n > 500 then you'll get
> 
> Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
> to change the limit. Be aware that exceeding your available stack space can
> crash MATLAB and/or your computer.

Unlikely, assuming each for-loop runs on 2 elements, how big is the number of combination before we run to recursive limit? 2^500 cases which is larger than 3e150 !

To OP, use NDGRID or any combination-generated tool in FEX to generate an array of combination your list of variables, then run a single for-loop on this array (or vectorize your code if you can.

Bruno