Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!news.glorb.com!news.aset.psu.edu!support1.mathforum.org!not-for-mail
From: leon Galushko <leonid.galushko@rwth-aachen.de>
Newsgroups: comp.soft-sys.matlab
Subject: code to solve a linear equity - Need help
Date: Sat, 12 Jan 2008 16:49:02 EST
Organization: The Math Forum
Lines: 31
Message-ID: <16745921.1200174572444.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1200174572 13385 144.118.30.135 (12 Jan 2008 21:49:32 GMT)
X-Complaints-To: news@support1.mathforum.org
NNTP-Posting-Date: Sat, 12 Jan 2008 21:49:32 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:445479


Hi,
i have had previosly adressed this question titled with "Lingo..." Now there are more MatLab experts which have good experience in MaTLab, so i rephrase the problem once more. The task is simply to solve the equity where
could be n amount of variables, like:
a1 * x1 + a2 * x2 + a3 * x3 = Y;
a1, a2 and a3 are given, the Y too; now is to find all
possible values which x1, x2 and x3 could take on to solve the equity; one constraint is, that x1,2, 3 have to be only integer, that is whole numbers. I will let the programm run till it had worked out all possible solving ways that could be for the given equation. I need all solving possibilities be outputed.

I tried in MatLab this code:
target_result = .....
% Iterations boundaries:
x1_start = 1;
x1_stop = 10000;
x2_start = 1;
x2_stop = 10000;
result = []; % initialize empy Array  
for i = x1_start:x1_stop
>      for j = x2_start:x2_stop
>          result = a * i + b * j;
>          if result == target_result
>              number_1 = i
>              number_1 = j
Resutls store in a matrix
>              result = [result; number_1 number_1];

   This do indeed, BUT the really problem is one cannot more than 2 or 3 variables, in case equation is longer, like that:
x1 * a1 + x2 * a2 + ..........x15 * a15 = Y;

There are then more than 15 loops, which MatLab not up to run in a time. 
Is there another way to make a better code for this model or this task?
Thanks
Leon