Re: Yet another user with poly_fit problems [message #86097 is a reply to message #86094] |
Thu, 03 October 2013 04:06   |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den torsdagen den 3:e oktober 2013 kl. 00:14:56 UTC+2 skrev Gus:
>
> Moreover, I expect to always have evenly spaced Y values, but increasingly spaced X values. Perhaps I need to look into the different fitting methods and determine whether one of them is acceptable for all future datasets.
This suggests to me that you should fit x as a function of y. (Although your example data set is not evenly spaced in y - perhaps the first y value should be 15.0 and not 15.9?)
Anyway, this works pretty nicely also with the data you specified, at least between the outermost y values:
c=poly_fit(y,x,4,/double)
cgplot,y,x,psym=9
yy=findgen(110)/20.+15
cgplot,yy,c[0]+yy*c[1]+yy^2*c[2]+yy^3*c[3]+yy^4*c[4],/over
or
cgplot,x,y,psym=9,/yno
cgplot,c[0]+yy*c[1]+yy^2*c[2]+yy^3*c[3]+yy^4*c[4],yy,/over
|
|
|