I have a set of non-linear data that has a linear segment close to the lift end of the curve. I wonder how to use the gradient function or any other function to locate the best range of points that represents the linear segment and thin find the slop and the interception point of this linear segment. An example of one of the sets of data is given below as x and y arrays
It this data is typical of your data, its not gonna happen.
Which linear segment are you referring to? Even if we ignore the apparent jump discontinuity in the middle of the curve, I don't see any obviously linear segment. Ok, take any pair of points, and we can put a linear segment between them. Otherwise, the curve seems to have a nice, smooth roll-over, with a continuously changing slope.
Getting a computer to do what you can see with your eyes is sometimes difficult. Getting a computer to do magic will be a bit harder.