Find an offset line from a linear portion of data set graph
12 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2016-4-24
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 个评论
Image Analyst
2016-4-24
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!