Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Gene
Date: Mon, 19 Jan 2009 20:05:04 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 24
Message-ID: <gl2mdg$7oe$1@fred.mathworks.com>
References: <gl29b9$6tb$1@fred.mathworks.com> <gl2i1a$cep$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1232395504 7950 172.30.248.35 (19 Jan 2009 20:05:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 19 Jan 2009 20:05:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:512549


function x=solvedot(z, y, head)

n = length(y);
x = (0:floor(z/y(1))).';
if n>1
    % recursive call
    z = z-y(1).*x;
    y = y(2:end);
    x = cell2mat(arrayfun(@(z,x) solvedot(z, y, x), z, x, ...
                 'UniformOutput', false));
end

if nargin>=3 % add a head column
    x = [head+zeros(size(x,1),1) x];
end

end % solvedot

% Command line
 x=solvedot(3.8, [1.213, 2.142, 3.112])

% Bruno

% Bruno