Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Linear Simlutaneous Equations
Date: Thu, 9 Oct 2008 19:08:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 35
Message-ID: <gclkqh$qt9$1@fred.mathworks.com>
References: <gcl2c8$hf$1@fred.mathworks.com> <48EE355C.9000106@yahoo.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1223579282 27561 172.30.248.38 (9 Oct 2008 19:08:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Oct 2008 19:08:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:494429


Freelance Embedded Systems Engineer <g9u5dd43@yahoo.com> wrote in message <48EE355C.9000106@yahoo.com>...

> X = inv(A)*B if the inverse exists.

Better use this
X = A \ B


> Otherwise, using the pseudoinverse to give you a leastsquare solution.
> X = A\B
> 

No, use X = pinv(A)*B or better still X=lsqr(A,B)

Example:

A=[1 2; 2 4]
B = [3; 6]

>> A\B
Warning: Matrix is singular to working precision. 

ans =

   NaN
   NaN

>> pinv(A)*B % Use lsqr

ans =

    0.6000
    1.2000

Bruno