Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: inverse matrix inv pinv linfactor ginv
Date: Sun, 4 Oct 2009 09:32:01 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 26
Message-ID: <ha9q2h$iuq$1@fred.mathworks.com>
References: <ha8r6f$pf7$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 1254648721 19418 172.30.248.35 (4 Oct 2009 09:32:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 4 Oct 2009 09:32:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:574760


"leo nidas" <bleonidas25@yahoo.gr> wrote in message <ha8r6f$pf7$1@fred.mathworks.com>...


 Note that X=[ones(n,1) x]. where n=300.
> 

When you do linear algebra, the first thing is to SCALE your variable correctly. Combine a vector of a magnitude 1 with x in the order of 1e73 is very bad.

I assume you want to find a linear polynomial coefficients that fit your data.

In this case work with xi := x/1e73 (xi will be between 0 and 1)

The fitting you want
y ~= b0 + b1*x becomes
y ~= [ones(n,1) x/1e73] * [b0 b1*1e73]'

solve for b2 = [b0 b1*1e73] by least square

xi = x/1e73
A2 =  [ones(n,1) xi] 
b2 = A2 \ y
b = [b2(1) b2(2)/1e73]

% Bruno

PS: A quick look of GINV indicates it's a not good quality code, I would say even amateurish one.