Hi Karen
The linear fit is Ok its just that your x values were not uniformly spaced. Hence when you plotted the fit on a waveform graph they looked distorted because you were essentially imposing a uniform spacing.
I've modified your code so that the x,y and x,yfit are shown on an XY Graph, which now shows the linear fit as a straight line.
Kurt Friday
www.sciware.com.au