Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: finding constants by LSQ
Date: Tue, 29 Jun 2010 17:54:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 17
Message-ID: <i0dbvt$9ca$1@fred.mathworks.com>
References: <i0d66p$je4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1277834045 9610 172.30.248.37 (29 Jun 2010 17:54:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 29 Jun 2010 17:54:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:649119

"MOOON MOOON" <shaheed107@yahoo.com> wrote in message <i0d66p$je4$1@fred.mathworks.com>...
> Hello, 
> I have the following equation:
> P = c0 + c1 * T + c2 * T^2 + c3 * H + c4 * H^2 + c5 * T * H
> and I have the hundreds of data for P, T and H
> How can I find the constants c0,c1 ......c5
> by least square method in MATLAB 7.0
> Thanks
> any help is highly appreciated..
- - - - - - - -
  Assuming P, T, and H are each column vectors of the same length,

 c = [ones(size(P),T,T.^2,H,H.^2,T.*H]\P;

The c vector contains [c0;c1;c2;c3;c4;c5] for a least squares solution.

Roger Stafford