MATLAB: How to divide a curve into two sections and fit straight lines for two sections in a curve separately and then find an intersection point of the lines. Kindly help

curve fittinggraphinterpolationpiecewise linear fitregression

There is a curve with say 3000 data points. I need to plot it first and divide it into two sections and fit straight lines separately. Then get the intersection of those straight lines and get the co-ordinate points.

Best Answer

I do that in the attached piecewise fitting demo. It divides the data into two sections and fits lines to the left section and right section and finds out where the lines intersect. Then it determines at what splitting index is the slope between the left line and right line the greatest so determine the best place to split the signal up into two "linear" sections.