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:
find y=f(x)

Subject: find y=f(x)

From: S?bastien Vilaseca

Date: 9 Mar, 2009 17:29:02

Message: 1 of 5

Hi,

I have a curve (I don't know it's equation) and I want to find Y such that Y=f(x) where x is given. Is there a way I can do it without having to fit the curve with polynomial approximation? Because when I fit the curve with polynomial approximation, it gives me curves but with a completely different shape...

Thanks a lot.

Subject: find y=f(x)

From: Lorenzo Guerrasio

Date: 9 Mar, 2009 18:39:01

Message: 2 of 5

"S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gp3jku$hf1$1@fred.mathworks.com>...
> Hi,
>
> I have a curve (I don't know it's equation) and I want to find Y such that Y=f(x) where x is given. Is there a way I can do it without having to fit the curve with polynomial approximation? Because when I fit the curve with polynomial approximation, it gives me curves but with a completely different shape...
>
> Thanks a lot.


The problem is unclear: do you have a set of data and you want to fit a curve?
You know your data are generated by a certain function that you don't know and you to infer?

Please be more specific.

Subject: find y=f(x)

From: S?bastien Vilaseca

Date: 9 Mar, 2009 19:18:01

Message: 3 of 5

"Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <gp3no5$p9m$1@fred.mathworks.com>...
> "S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gp3jku$hf1$1@fred.mathworks.com>...
> > Hi,
> >
> > I have a curve (I don't know it's equation) and I want to find Y such that Y=f(x) where x is given. Is there a way I can do it without having to fit the curve with polynomial approximation? Because when I fit the curve with polynomial approximation, it gives me curves but with a completely different shape...
> >
> > Thanks a lot.
>
>
> The problem is unclear: do you have a set of data and you want to fit a curve?
> You know your data are generated by a certain function that you don't know and you to infer?
>
> Please be more specific.

Yes, I have a set of 10 datapoints (x,y). I plotted the curve that rely those points. What I want to know is the value of y for EVERY x, not only for those that I have in my dataset.

Thanks.

Subject: find y=f(x)

From: Lorenzo Guerrasio

Date: 10 Mar, 2009 09:13:01

Message: 4 of 5

"S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gp3q19$48$1@fred.mathworks.com>...
> "Lorenzo Guerrasio" <lorenzo.guerrasio@email.it> wrote in message <gp3no5$p9m$1@fred.mathworks.com>...
> > "S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gp3jku$hf1$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I have a curve (I don't know it's equation) and I want to find Y such that Y=f(x) where x is given. Is there a way I can do it without having to fit the curve with polynomial approximation? Because when I fit the curve with polynomial approximation, it gives me curves but with a completely different shape...
> > >
> > > Thanks a lot.
> >
> >
> > The problem is unclear: do you have a set of data and you want to fit a curve?
> > You know your data are generated by a certain function that you don't know and you to infer?
> >
> > Please be more specific.
>
> Yes, I have a set of 10 datapoints (x,y). I plotted the curve that rely those points. What I want to know is the value of y for EVERY x, not only for those that I have in my dataset.
>
> Thanks.

Then it is not clear this "it gives me curves but with a completely different shape..."
Different shape with respect to what? If you want your curve to pass throu all the points, you'll maybe interested in help-->interpolation
Otherwise polyfit + polyval, but you should you a proper number of paramenters to fit (not too much,not too few...you have only 10 points, it depends on the noise).

In the formar case, you'll not have an y=f(x), but just a Y(X)...

Regards

Subject: find y=f(x)

From: Pj

Date: 10 Mar, 2009 10:14:01

Message: 5 of 5

"S?bastien Vilaseca" <seb2000@bluewin.ch> wrote in message <gp3jku$hf1$1@fred.mathworks.com>...
> Hi,
>
> I have a curve (I don't know it's equation) and I want to find Y such that Y=f(x) where x is given. Is there a way I can do it without having to fit the curve with polynomial approximation? Because when I fit the curve with polynomial approximation, it gives me curves but with a completely different shape...
>
> Thanks a lot.

The real problem here is that you seem to be expecting a bit much from MATLAB.

If you have a collection of points but no idea of the function that links them then there are any number of methods of fitting a line to those points. Any of these methods will provide a fit of greater or lesser accuracy depending on the amount of freedom you allow the parameter estimation process and the freedom implicit in the equation being fitted.

For example a 10th order polynomial will fit your data perfectly but, as I think you have already experienced, it probably isn't what you're looking for if you intent to interpolate. A straight line will be less uneven but has little freedom so may not fit very well.

The key is to identify a likely function for f(x) then use MATLAB it to parameterise it.

Further reading might include smoothing functions which are pretty much what you seem to be talking about.

Tags for this Thread

No tags are associated with 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