Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Generating a function from data
Replies: 1   Last Post: Mar 11, 2013 10:39 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Derek Goring

Posts: 3,644
Registered: 12/7/04
Re: Generating a function from data
Posted: Mar 11, 2013 10:39 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Tuesday, March 12, 2013 2:58:17 PM UTC+13, Jerome wrote:
> >
>
> > I agree with dpb.
>
> > Unless there is a theoretical reason why your function should be a polynomial, why try fitting a polynomial? Or any other function for that matter.
>
> >
>
> > Interpolation, using splines, is the answer. And if splines don't work, try PCHIP - in my experience PCHIP always works, whereas splines don't always.
>
> >
>
> >
>
>
>
>
>
>
>
> There is absolutely no mathematical reason why this function should be polynomial. In fact it is a very bad fit for a polynomial. The only reason I am doing this is so I can define a function that can be used in numerical integration routines as a driving function
>
>
>
> i.e.
>
>
>
> df/dt = terrible polynomial(t) + another function
>
>
>
> (the parameters passed to the ode routines are the polynomial coefficients) I know this is currently a horrendous, and I am trying to improve it
>
>
>
>
>
>
>
> can this spline iterpolation sort this? I am looking into it now, but I am quite bad at matlab and would definetly appreciate comments if you know of anything in particular.


There's nothing much to look into.
help interp1
gives it all.
You will probably want to invoke this:
PP = INTERP1(X,Y,METHOD,'pp')
described lower down in the help so that you don't have to recalculate the knots everytime you evaluate your function.

help ppval
will also be useful.





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.