From: MOOON MOOON on

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..
From: Matt J on
There are many polynomial fitting tools on the File Exchange.
From: John D'Errico on
"MOOON MOOON" <shaheed107(a)yahoo.com> wrote in message <i0d66p$je4$1(a)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..

Download polyfitn from the FEX.

http://www.mathworks.com/matlabcentral/fileexchange/10065

John
From: Roger Stafford on
"MOOON MOOON" <shaheed107(a)yahoo.com> wrote in message <i0d66p$je4$1(a)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
From: MOOON MOOON on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i0d6n4$mg8$1(a)fred.mathworks.com>...
> There are many polynomial fitting tools on the File Exchange.

Thanks,

but my polynomial is ready, and it has two independent variables T and H

the polynomial is:

P = c0 + c1 * T + c2 * T^2 + c3 * H + c4 * H^2 + c5 * T * H


assume we have

T=[31 31 31 35 35 35 31 33 32 34 33 32 33 33]

H=[77 72 86 52 57 67 82 75 70 28 31 72 80 44]

P=[39 39 40 39 37 39 38 38 38 37 37 38 39 39]

So, I found that the following equation fit my data:

P = c0 + c1 * T + c2 * T^2 + c3 * H + c4 * H^2 + c5 * T * H

then, I want to find the constants c0,c1,c2,c3,c4 and c5

by least square method

regards