Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
finding constants by LSQ

Subject: finding constants by LSQ

From: MOOON MOOON

Date: 29 Jun, 2010 16:15:22

Message: 1 of 5


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..

Subject: finding constants by LSQ

From: Matt J

Date: 29 Jun, 2010 16:24:04

Message: 2 of 5

There are many polynomial fitting tools on the File Exchange.

Subject: finding constants by LSQ

From: John D'Errico

Date: 29 Jun, 2010 17:48:04

Message: 3 of 5

"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..

Download polyfitn from the FEX.

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

John

Subject: finding constants by LSQ

From: Roger Stafford

Date: 29 Jun, 2010 17:54:05

Message: 4 of 5

"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

Subject: finding constants by LSQ

From: MOOON MOOON

Date: 29 Jun, 2010 17:55:22

Message: 5 of 5

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i0d6n4$mg8$1@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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us