http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229
MATLAB Central Newsreader  How can i retrieve a function?
Feed for thread: How can i retrieve a function?
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 23 Mar 2010 11:08:05 +0000
How can i retrieve a function?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229#728865
Covadonga dubrovnic
How can i retrieve a function, possibly in a periodic form, from a figure that was made by using the cubic spline interpolation on a set of datas?

Tue, 23 Mar 2010 12:08:07 +0000
Re: How can i retrieve a function?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229#728880
Covadonga dubrovnic
"Covadonga dubrovnic" <covadonga.project@gmail.com> wrote in message <hoa7el$jqo$1@fred.mathworks.com>...<br>
> How can i retrieve a function, possibly in a periodic form, from a figure that was made by using the cubic spline interpolation on a set of datas?<br>
<br>
<br>
I thought of helping you out with this problem by including the code i used to generate my figure.<br>
[code]<br>
<br>
clear<br>
close all<br>
clc<br>
<br>
x = 0:23; %cam rotation angle%<br>
y = [15 15 13.5 9.5 4 0 3 6.5 9.5 12 13.5 15 15 13 11 9 6 3.5 0.5 4 9 13 15 15];<br>
%piston height in mm%<br>
cs = spline(x,[0 y 0]);<br>
xx = linspace(0,23,100000);<br>
figure (1);<br>
plot(x,y,'o',xx,ppval(cs,xx),'');<br>
<br>
[/code]

Tue, 23 Mar 2010 12:18:06 +0000
Re: How can i retrieve a function?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229#728885
Sadik
Hi Covadonga,<br>
<br>
This should help you:<br>
<br>
<a href="http://alenblog.wordpress.com/2009/07/21/retrievedatafromfigmatlabfigurefile/">http://alenblog.wordpress.com/2009/07/21/retrievedatafromfigmatlabfigurefile/</a><br>
<br>
Best.

Tue, 23 Mar 2010 12:22:38 +0000
Re: How can i retrieve a function?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229#728888
Walter Roberson
Covadonga dubrovnic wrote:<br>
> "Covadonga dubrovnic" <covadonga.project@gmail.com> wrote in message <br>
> <hoa7el$jqo$1@fred.mathworks.com>...<br>
>> How can i retrieve a function, possibly in a periodic form, from a <br>
>> figure that was made by using the cubic spline interpolation on a set <br>
>> of datas?<br>
> <br>
> <br>
> I thought of helping you out with this problem by including the code i <br>
> used to generate my figure.<br>
> [code]<br>
> <br>
> clear<br>
> close all<br>
> clc<br>
> <br>
> x = 0:23; %cam rotation angle%<br>
> y = [15 15 13.5 9.5 4 0 3 6.5 9.5 12 13.5 15 15 13 11 9 6 <br>
> 3.5 0.5 4 9 13 15 15];<br>
> %piston height in mm%<br>
> cs = spline(x,[0 y 0]);<br>
> xx = linspace(0,23,100000);<br>
> figure (1);<br>
> plot(x,y,'o',xx,ppval(cs,xx),'');<br>
> <br>
> [/code]<br>
<br>
Could you clarify which function you are attempting to recover? Is the <br>
goal to examine the figure and work backwards from there to the set of x <br>
and y values that were used to create the cubic spline? Or is the goal <br>
to recover the cubic spline coefficients? Or is the goal to try to <br>
figure out from the fitted spline what the original function that y <br>
samples is?<br>
<br>
If you are trying to determine the original function that y samples, <br>
then you cannot do that, not unless you can place constraints as to what <br>
kind of functions might reasonably be in effect, and not unless you <br>
define a mechanism for deciding which of several candidates is the <br>
"real" function. Which is not always an easy thing to do: there is <br>
always a polynomial that fits the data perfectly, but the "real" <br>
function might instead be (e.g.) a sine wave that has a small bit of <br>
measurement error involved. You would need to define some kind of <br>
preference hierarchy, where if the fitting error is too large then you <br>
move to the next (less preferable) function form.

Tue, 23 Mar 2010 12:43:38 +0000
Re: How can i retrieve a function?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229#728900
Covadonga dubrovnic
Walter Roberson <roberson@hushmail.com> wrote in message <hoabqf$bmg$1@canopus.cc.umanitoba.ca>...<br>
> Covadonga dubrovnic wrote:<br>
> > "Covadonga dubrovnic" <covadonga.project@gmail.com> wrote in message <br>
> > <hoa7el$jqo$1@fred.mathworks.com>...<br>
> >> How can i retrieve a function, possibly in a periodic form, from a <br>
> >> figure that was made by using the cubic spline interpolation on a set <br>
> >> of datas?<br>
> > <br>
> > <br>
> > I thought of helping you out with this problem by including the code i <br>
> > used to generate my figure.<br>
> > [code]<br>
> > <br>
> > clear<br>
> > close all<br>
> > clc<br>
> > <br>
> > x = 0:23; %cam rotation angle%<br>
> > y = [15 15 13.5 9.5 4 0 3 6.5 9.5 12 13.5 15 15 13 11 9 6 <br>
> > 3.5 0.5 4 9 13 15 15];<br>
> > %piston height in mm%<br>
> > cs = spline(x,[0 y 0]);<br>
> > xx = linspace(0,23,100000);<br>
> > figure (1);<br>
> > plot(x,y,'o',xx,ppval(cs,xx),'');<br>
> > <br>
> > [/code]<br>
> <br>
> Could you clarify which function you are attempting to recover? Is the <br>
> goal to examine the figure and work backwards from there to the set of x <br>
> and y values that were used to create the cubic spline? Or is the goal <br>
> to recover the cubic spline coefficients? Or is the goal to try to <br>
> figure out from the fitted spline what the original function that y <br>
> samples is?<br>
> <br>
> If you are trying to determine the original function that y samples, <br>
> then you cannot do that, not unless you can place constraints as to what <br>
> kind of functions might reasonably be in effect, and not unless you <br>
> define a mechanism for deciding which of several candidates is the <br>
> "real" function. Which is not always an easy thing to do: there is <br>
> always a polynomial that fits the data perfectly, but the "real" <br>
> function might instead be (e.g.) a sine wave that has a small bit of <br>
> measurement error involved. You would need to define some kind of <br>
> preference hierarchy, where if the fitting error is too large then you <br>
> move to the next (less preferable) function form.<br>
<br>
Thank you very much indeed, your explanation was very helpful, i'll try to explain myself better. <br>
My goal, as you already figured out, is to recover the cubic spline coefficients. I know that there are several functions that could fit in the curve i obtained, but my problem, before having to decide wich solution is the best, is to obtain at least ONE or two possible solutions.<br>
Btw the hierarchy i'll apply will not be too strict because it's a mechanical problem, therefore heavy approximation is a common practice, in particular during the first steps of the design

Tue, 23 Mar 2010 13:42:14 +0000
Re: How can i retrieve a function?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/277229#728915
Steven Lord
<br>
"Covadonga dubrovnic" <covadonga.project@gmail.com> wrote in message <br>
news:hoad1q$h41$1@fred.mathworks.com...<br>
> Walter Roberson <roberson@hushmail.com> wrote in message <br>
> <hoabqf$bmg$1@canopus.cc.umanitoba.ca>...<br>
>> Covadonga dubrovnic wrote:<br>
>> > "Covadonga dubrovnic" <covadonga.project@gmail.com> wrote in message <br>
>> > <hoa7el$jqo$1@fred.mathworks.com>...<br>
>> >> How can i retrieve a function, possibly in a periodic form, from a <br>
>> >> figure that was made by using the cubic spline interpolation on a set <br>
>> >> of datas?<br>
<br>
*snip*<br>
<br>
> Thank you very much indeed, your explanation was very helpful, i'll try to <br>
> explain myself better. My goal, as you already figured out, is to recover <br>
> the cubic spline coefficients. I know that there are several functions <br>
> that could fit in the curve i obtained, but my problem, before having to <br>
> decide wich solution is the best, is to obtain at least ONE or two <br>
> possible solutions.<br>
> Btw the hierarchy i'll apply will not be too strict because it's a <br>
> mechanical problem, therefore heavy approximation is a common practice, in <br>
> particular during the first steps of the design<br>
<br>
If you still have the output of your SPLINE call, it contains the <br>
coefficients. Look at cs  the cs.coefs field is what you're looking for. <br>
One caveat if you're going to evaluate this function directly; the function <br>
represented by the coefficients is a function of (xleftbreak) not of x, so <br>
either adjust your x data appropriately or call PPVAL (which handles that <br>
automatically.)<br>
<br>
 <br>
Steve Lord<br>
slord@mathworks.com<br>
comp.softsys.matlab (CSSM) FAQ: <a href="http://matlabwiki.mathworks.com/MATLAB_FAQ">http://matlabwiki.mathworks.com/MATLAB_FAQ</a>