How to add two different linear fits to the same graph
Show older comments
I have tried looking for built-in plotting options to create a bi-linear fit for data but it appears this is something I probably have to code myself. Below I attached an example of the data I am trying to fit:

I want to be able to fit a linear regression to the 'flat' and 'steep' regions of this graph without having to manually create two data sets, regressions, and a combined plot. The point of this is to find the intersection point of the two linear regressions.
Perhaps the best way of solving the problem is to find where concavity/double derivative is maximized, however I really do not know how to go about coding this. Any ideas or help would be greatly appreciated.
4 Comments
dpb
on 27 Aug 2018
I've posted this a couple times in the past but I don't seem to have saved a link...let me search for it and see if can find it rather than rewriting from scratch. I thought I had a utility function but don't see it now, either... :(
Joshua Everts
on 27 Aug 2018
Joshua Everts
on 27 Aug 2018
Edited: dpb
on 27 Aug 2018
dpb
on 27 Aug 2018
How about attach a .mat file with a couple of your curves to illustrate with? I did find my piecewise m-file (it was in an old installation folder).
I don't know how well the linear section is going to work with the RH section of your data; it looks more like a quadratic might be in order.
Accepted Answer
More Answers (0)
Categories
Find more on Linear Predictive Coding in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!