Thread Subject: Matlab: least square fit with more than one variables

Subject: Matlab: least square fit with more than one variables

From: itubeusa

Date: 7 Jun, 2008 13:39:02

Message: 1 of 3

Hello,
Is there anyone can help me with the following problem in Matlab?
Suppose I have a function:

sqrt((1/N)*sum((x+(a+b*x+c*x*x)*(y-800)-z)^2)),

where N is number of data points, x,y,z are known experiment data (1D arrays with same size) which can be read from file. Will need to find a,b,c so the above function is minimized.
Any help is highly appreciated.
Thanks

Subject: Matlab: least square fit with more than one variables

From: Greg Heath

Date: 7 Jun, 2008 14:11:45

Message: 2 of 3

On Jun 7, 9:39=A0am, itubeusa <itube...@yahoo.com> wrote:
> Hello,
> Is there anyone can help me with the following problem in Matlab?
> Suppose I have a function:
>
> sqrt((1/N)*sum((x+(a+b*x+c*x*x)*(y-800)-z)^2)),
>
> where N is number of data points, x,y,z are known experiment data (1D arra=
ys with same size) which can be read from file. Will need to find a,b,c so t=
he above function is minimized.
> Any help is highly appreciated.
> Thanks

Your notation is confusing. It looks like it can be reduced to

Minimize w'*w

where

w =3D x - z + ( y - 800 ) .* ( a + b * x + c * x.^2)

Hope this helps.

Greg

Subject: Matlab: least square fit with more than one variables

From: richardstartz@comcast.net

Date: 7 Jun, 2008 15:41:57

Message: 3 of 3

On Sat, 7 Jun 2008 07:11:45 -0700 (PDT), Greg Heath
<heath@alumni.brown.edu> wrote:

>On Jun 7, 9:39 am, itubeusa <itube...@yahoo.com> wrote:
>> Hello,
>> Is there anyone can help me with the following problem in Matlab?
>> Suppose I have a function:
>>
>> sqrt((1/N)*sum((x+(a+b*x+c*x*x)*(y-800)-z)^2)),
>>
>> where N is number of data points, x,y,z are known experiment data (1D arrays with same size) which can be read from file. Will need to find a,b,c so the above function is minimized.
>> Any help is highly appreciated.
>> Thanks
>
>Your notation is confusing. It looks like it can be reduced to
>
>Minimize w'*w
>
>where
>
>w = x - z + ( y - 800 ) .* ( a + b * x + c * x.^2)
>
>Hope this helps.
>
>Greg

If you follow-up on Greg's suggestion, this becomes a simple least
squares problem that can be solved with the backslash operator. Think
of the equation as

(x-z) = a*(y-800) + b*(y-800)*x + b*(y-800)*x.^2

-Dick Startz

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com