Could someone explain this straight line function?
7 views (last 30 days)
I found this bit of code in another help thread:
func = @(x)a(1) + (a(2)-b(2))/(a(1)-b(1))*(x-a(1));
I have gotten it to work in matlab fine but I dont actually understand what it is doing on a mathimatical level.
Could someone explain so I solve some errors im having with similar functions?
More Answers (1)
David Hill on 14 Jan 2021
It is point-slope form of a line. If the points are a=[x2, y2] and b=[x1, y1], then:
func =@(x) m*(x-a(1))+a(2);%above equation seems to be wrong, should be +a(2)
func =@(x) m*(x-b(1))+b(2);%same thing just using other point