Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Gene
Date: Mon, 19 Jan 2009 20:40:18 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 15
Message-ID: <gl2ofi$gfs$1@fred.mathworks.com>
References: <gl29b9$6tb$1@fred.mathworks.com> <gl2i1a$cep$1@fred.mathworks.com> <gl2mdg$7oe$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1232397618 16892 172.30.248.37 (19 Jan 2009 20:40:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 19 Jan 2009 20:40:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:512555


I don't necessarily think this is more efficient, but here is a vectorized approach.

function X = solvedott(z,y)
lngth = length(y);
X = repmat({0:max(floor(z./y(y~=0)))},1,lngth) ;
[X{1:lngth}] = ndgrid(X{:}); 
X = fliplr(reshape(cat(lngth+1,X{:}),[],lngth)) ;
Y = y(ones(1,size(X,1)),1:lngth);
X = X(sum(X.*Y,2)<=z,:);





_UYfQ*QdS``0}YdvU_Q\o]W\_dve=]_oeoSRooQQ_UX[U^_oXRIQoXoi5Q^