How to extend a best fit line?

3 views (last 30 days)
Schirin Sellmann
Schirin Sellmann on 12 Oct 2017
Commented: Md Ashraf on 22 Nov 2018
Hi, I divided the datapoints of a fault scarp profile into three datasets for the footwall, scarp slope and hanging wall and plotted the respective best fit lines. What is the easiest way to just extend the length of the best fit line for the scarp so that it crosses the best fit lines of the footwall and the hanging wall?

Accepted Answer

KSSV
KSSV on 12 Oct 2017
P1 = rand(2,1) ;
P2 = rand(2,1) ;
% line(P1,P2)
plot([P1(1) P2(1)],[P1(2) P2(2)],'b','linewidth',5)
%%Extend line
m = (P2(2)-P1(2))/(P2(1)-P1(1)) ; % slope of line
N = 100 ;
x = linspace(-2,2,N) ; % specify your x limits
y = P1(2)+m*(x-P1(1)) ; % y = y1+m*(x-x1) ;
hold on
plot(x,y,'.r')
  6 Comments
Image Analyst
Image Analyst on 13 Oct 2017
Schirin, can you please click the "Accept this answer" link so KSSV gets credit (reputation points) for his efforts to help you.
Md Ashraf
Md Ashraf on 22 Nov 2018
x1=302;
x2=380;
y1=1;
y2=101;
here is my point of the line . how I increase the size of this line?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!