Path: news.mathworks.com!not-for-mail
From: "Leon galushko" <leonid.galushko@rwth-aachen.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: linear equation with restrictions
Date: Sat, 19 Jul 2008 18:54:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 62
Message-ID: <g5td8a$s9q$1@fred.mathworks.com>
References: <g5sgla$b7r$1@fred.mathworks.com> <g5sjfa$fbg$1@fred.mathworks.com>
Reply-To: "Leon galushko" <leonid.galushko@rwth-aachen.de>
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 1216493642 28986 172.30.248.35 (19 Jul 2008 18:54:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 19 Jul 2008 18:54:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1183838
Xref: news.mathworks.com comp.soft-sys.matlab:480466


Hi Bruno,
thanks indeed for your proposal to solve this!
I'm beginner of MatLab und therofore very thankfull for
initial support.
Now i have a question to this: g so far as i grasped is the
number of factors which are in a equation (C1, C2). Why is 
'all the numbers generated by the ihs of (eqt1) must be
multiple of 2 (=g)'? And what is ihs?
Question2: c1 and c2 must be onle positiv, c1, c2 > 0.
How can this be secured?
Thanks!
Leon


"Bruno Luong" <b.luong@fogale.fr> wrote in message
<g5sjfa$fbg$1@fred.mathworks.com>...
> "Leon galushko" <leonid.galushko@rwth-aachen.de> wrote in
> message <g5sgla$b7r$1@fred.mathworks.com>...
> > Hi,
> > i would carry out the following equation
> > (figures are as examples):
> > 
> > A1 * c1 + A2 * c2 = b
> > A = [2.30 4.56]
> > b = 57.4
> 
> OK, in order to avoid work with float, I'll transform your
> fisrt equation by multiplying it by 100
> 
> Ax100_1 * c1 + Ax100_2 * c2 = bx100  (eqt 1)
> 
> Ax100 = [230 456]
> bx100 = 5740
> 
> Now search for greater common divisor of Ax1000 by MATLAB
> function GCD:
> 
> [g D1 D2]=gcd(Ax100(1),Ax100(2))
> % it is gcd(230,456) % g ==2, D1=-113, D2=57
> 
> Which mean
> All the numbers generated by the lhs of (eqt 1) is 
> + multiple of 2 (=g), and furthermore
> + g = 2 = -113*230  + 57*456 = 
>           -113*Ax100(1)  + 47*Ax100(2) (eqt 2).
> 
> Now all you need is to see whereas bx100 is divisible by g.
> 
> if mod(bx100 ,g)==0 % yes
>   C1 = D1 * bx100/g % -324310
>   C2 = D2 * bx100/g % +163590
> else
>   error('No integer solution exists') 
> end
> 
> Verification:
> 
> C1*2.30+C2*4.56 % 57.4000
> 
> Bruno
>