Thread Subject: Curve fitting - How to get polynomial of form ax^2 + 0x + 0?

Subject: Curve fitting - How to get polynomial of form ax^2 + 0x + 0?

From: David Migl

Date: 9 Jul, 2008 04:06:03

Message: 1 of 5

Hi,

I am using MATLAB to fit a curve to data. I have a physics
formula of the form y=ax^2 and I am trying to determine the
value of the constant _a_ using the data. When I fit a
second degree polynomial to the data (using polyfit), MATLAB
gives me the constants a b and c of the polynomial in the
form of ax^2 + bx + c. Of course, that doesn't help me find
_a_ for my formula. The extra terms of power<2 throw me off.
I need a polynomial of the form ax^2 + 0x + 0 that fits the
data. How can I accomplish this?

Subject: Curve fitting - How to get polynomial of form ax^2 + 0x + 0?

From: Miroslav Balda

Date: 9 Jul, 2008 04:21:02

Message: 2 of 5

"David Migl" <migl.spam@gmail.com> wrote in message
<g51dfa$q8h$1@fred.mathworks.com>...
> Hi,
>
> I am using MATLAB to fit a curve to data. I have a physics
> formula of the form y=ax^2 and I am trying to determine the
> value of the constant _a_ using the data. When I fit a
> second degree polynomial to the data (using polyfit), MATLAB
> gives me the constants a b and c of the polynomial in the
> form of ax^2 + bx + c. Of course, that doesn't help me find
> _a_ for my formula. The extra terms of power<2 throw me off.
> I need a polynomial of the form ax^2 + 0x + 0 that fits the
> data. How can I accomplish this?

Hi
Very simply. Your problem is a special form of polynomial.
The coefficient a may be found by the statement
     
     a = x(:).^2\y(:);

It is a reduced form of the polynomial fit, coefficient of
which can be found from the formula (should x and y be
column vectors)

     c = [ones(size(x)), x, x.^2, x.^3,...]\y

Have a nice day.
Mira

Subject: Curve fitting - How to get polynomial of form ax^2 + 0x + 0?

From: David Migl

Date: 9 Jul, 2008 04:30:20

Message: 3 of 5

"Miroslav Balda" <balda.nospam@cdm.it.cas.cz> wrote in
message <g51ebe$438$1@fred.mathworks.com>...
> "David Migl" <migl.spam@gmail.com> wrote in message
> <g51dfa$q8h$1@fred.mathworks.com>...
> > Hi,
> >
> > I am using MATLAB to fit a curve to data. I have a physics
> > formula of the form y=ax^2 and I am trying to determine the
> > value of the constant _a_ using the data. When I fit a
> > second degree polynomial to the data (using polyfit), MATLAB
> > gives me the constants a b and c of the polynomial in the
> > form of ax^2 + bx + c. Of course, that doesn't help me find
> > _a_ for my formula. The extra terms of power<2 throw me off.
> > I need a polynomial of the form ax^2 + 0x + 0 that fits the
> > data. How can I accomplish this?
>
> Hi
> Very simply. Your problem is a special form of polynomial.
> The coefficient a may be found by the statement
>
> a = x(:).^2\y(:);
>
> It is a reduced form of the polynomial fit, coefficient of
> which can be found from the formula (should x and y be
> column vectors)
>
> c = [ones(size(x)), x, x.^2, x.^3,...]\y
>
> Have a nice day.
> Mira
>
>

Thank you very much for your reply; I can almost comprehend
it; forgive my ignorance, but could you please tell me what
x and y represent?

Subject: Curve fitting - How to get polynomial of form ax^2 + 0x + 0?

From: Miroslav Balda

Date: 9 Jul, 2008 04:54:02

Message: 4 of 5

"David Migl" <migl.spam@gmail.com> wrote in message
<g51ess$8bo$1@fred.mathworks.com>...
:
SNIP
:
> Thank you very much for your reply; I can almost comprehend
> it; forgive my ignorance, but could you please tell me what
> x and y represent?

(x,y) are coordinates of your observations (points).
x is column vector of independent variable values, and
y is a column vector of the same size as x of values of
dependent variable.

Mira

Subject: Curve fitting - How to get polynomial of form ax^2 + 0x + 0?

From: David Migl

Date: 9 Jul, 2008 05:01:03

Message: 5 of 5

Ah, I knew it had to be something simple like that. I tried
the formula you gave me and it worked out perfectly; I
extend my deepest gratitude to your for your help as I
couldn't have figured it out otherwise.

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reduced form David Migl 9 Jul, 2008 00:33:39
polynomial David Migl 9 Jul, 2008 00:33:39
curve fit Miroslav Balda 9 Jul, 2008 00:25:06
rssFeed for this Thread

Contact us at files@mathworks.com