Re: Duplicate Elements in List cause Errors with Interpolation
- To: mathgroup@smc.vnet.net
- Subject: [mg10707] Re: Duplicate Elements in List cause Errors with Interpolation
- From: Paul Abbott <paul@physics.uwa.edu.au>
- Date: Fri, 30 Jan 1998 04:24:42 -0500
- Organization: University of Western Australia
- References: <6ahp25$pkv@smc.vnet.net>
Todd Rose wrote:
> This doesn't seem to work for me. I can't figure out how to remove the
> duplicate in the first element of the data pairs (0.4375). Union only
> seems to work if they are alike in both the abscissa and the ordinate.
> Perhaps I can use a test with the Union command, but I have not been
> able to figure out the format for the "spec".
In[2]:= mydata = Union[mydata, SameTest -> (First[#1] == First[#2] & )];
removes duplicate first elements.
In[3]:= lp = ListPlot[mydata];
In[4]:= myfunction = Interpolation[%, InterpolationOrder -> 1];
However, for this dataset, why use Interpolation anyway? I think a Fit
is a much better idea:
In[5]:= fit[x_] = Fit[mydata, {1, Sqrt[x], x}, x] Out[5]= -17.9046 x +
116.859 Sqrt[x] - 13.4646
In[6]:=Plot[fit[x], {x, 0, 5.3}];
In[7]:= Show[%, lp];
Cheers,
Paul
____________________________________________________________________
Paul Abbott Phone: +61-8-9380-2734
Department of Physics Fax: +61-8-9380-1014
The University of Western Australia Nedlands WA 6907
mailto:paul@physics.uwa.edu.au AUSTRALIA
http://www.pd.uwa.edu.au/~paul
God IS a weakly left-handed dice player
____________________________________________________________________