Find an offset line from a linear portion of data set graph
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dommal
am 24 Apr. 2016
Kommentiert: Image Analyst
am 24 Apr. 2016
Hi everyone!
I would like to plot an offset line (constant offset) from a linear region in my data set. Basically I want to get a line like in the graph below (from excel).

I can't really figure this out. My data set is an array with number of points for x and y and plotting it is not a problem.
Thank you for your suggestions,
Dominika
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 24 Apr. 2016
Just shift the X by the amount you want to shift it:
shiftedX = x + 0.6;
plot(x, y, 'b-', 'LineWidth', 3);
hold on;
plot(shiftedX, y, 'r-', 'LineWidth', 3);
2 Kommentare
Image Analyst
am 24 Apr. 2016
Since you don't have very many points, the brute force way might be fine. Just fit lines from every point to every later point that is at least 2 points away. Then compute the residuals (which is the fitted minus the actual). Any line that fits reasonably well will have a low average residual and lines that are poor fits will have high average residuals. As you can imagine, there are going to be several lines that are reasonably straight so you'll have to pick some criteria for what line is "best", like it must be longer than 0.8 in the x direction and have an average residual less than 100, or whatever. Even then, there might be a few lines that meet your criteria.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!