Approximating a plot by piece wise straight lines

1 view (last 30 days)
I want to approximate the points on the plot as shown in the figure 1 with the straight lines as shown in the figure 2. Are there any algorithms for doing this in matlab?
Figure 1:
Figure 2:

Accepted Answer

John D'Errico
John D'Errico on 7 Apr 2015
This has nothing to do with image analysis, except that the data may have been derived from an image.
As for there being an algorithm to do this in MATLAB, no. You envision a curve that has a shape that you can see, but only you know why it is you chose that specific curve, ignoring some bumps, while following others. As well, the "curve" that you have not drawn is not actually a function, but a general piecewise curve with some vertical segments. See that the curve you have drawn has an infinite slope at multiple locations, or perhaps you just intended those points as discontinuities. I cannot really be sure from the way you have drawn it.
The human eye/brain is good at finding a shape in what it sees, but much of the time, making a computer do the same is less easy. You need to carefully quantify the rules you would use. In general, when you want to do something that nobody else has a need for, it is time to write it yourself. Sorry.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!