Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Least squares fitting
Date: Tue, 13 May 2008 15:55:06 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 28
Message-ID: <g0cdkq$1ck$1@fred.mathworks.com>
References: <g0ccfp$jd9$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
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 1210694106 1428 172.30.248.38 (13 May 2008 15:55:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 May 2008 15:55:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:468184


"Zaira " <Zaira.Girbau-Garcia@jrc.it> wrote in message 
<g0ccfp$jd9$1@fred.mathworks.com>...
> I need to find the coefficients k1-k6 of the following equation:
> 
> P = G*(k1 + k2*T + k3*log(G) + k4*(log(G)).^2 + k5*T*log(G)+
> k6*T*(log(G)).^2+k7*T.^2);
> 
> The experimental data I have are P, G and T.
> 
> Is there any MATLAB function in order to obtain the
> coefficients using least-squares fitting? 
> Do I need the Curve Fitting Toolbox?

This is a linear least squares problem. You can
use my polyfitn to do the fitting. Find it on the
file exchange.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=10065&objectType=FILE

Assuming that P,G,T are all column vectors, 

LG = log(G);
model = polyfitn([G,LG,T],P,'G, G*T, G*LG, G*LG^2, G*LG*T, G*T*LG^2, 
G*T^2');

HTH,
John