Info
This question is closed. Reopen it to edit or answer.
How to draw linear lines on a set of data and find which line has the most points on it?
1 view (last 30 days)
Show older comments
I have a set of error-data and this error increases per inch (distance). But this data is not perfectly linear. I want to draw a number of linear lines on the plotted graph and then check which line has the most data points on it or near to it. How should i do it? The data for this is
inch (distance)=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14--------25 26 27]; error=[-5.5494 -6.7142 -4.2772 -4.4059 -3.7628 -4.2873 -3.2144 -2.058 -2.1906 -2.3534 -1.5007 -1.9778 -1.4085 0 0.6107 1.2219 2.0251 0.9636 1.98 2.1989 3.052 4.5974 3.4878 4.3893 4.8776 3.4843 2.5935];
The plotted graph is attached herewith.
Thanks in advance
1 Comment
Guillaume
on 23 Jun 2016
Why don't you want to do a least square fit rather than come up with your own fitting algorithm?
Answers (1)
KSSV
on 23 Jun 2016
1. You can use knnsearch to find how many points are closer to a given points. 2. You can use find(x<xmin & x>xmax) to know points lying between [xmin, xmax].
Hope you got the gist.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!