Define tangent line along each boundary points of a curve
6 次查看(过去 30 天)
显示 更早的评论
Dear experts, I am looking for suggestions for the problem below.
For each point at a curve, the tangent of this point is defined by the straight line that best fits (in the sense of least-squared error) a neighbourhood of p points at the curve, centred on the point of interest. My aim is to get the slope of such tangent at each curve point. Matlab function gradient won't work since our definition of "tangent" is different. Many thanks for your help.
0 个评论
回答(1 个)
Image Analyst
2014-10-2
You have to get a handful of points on the boundary around the point you want the tangent of, like say 11 points or something. Then fit to a curve, like say, a quadratic:
coefficients = polyfit(x, y, 2);
Then, from basic calculus, the slope of a quadratic a1*x^2 + a2 is 2*a1. So make up a line with that slope
slope = 2 * coefficients(1);
using the point slope formula (y-yp)= slope*(x-xp). You can just plug in two (x,y) endpoints for a line segment and use line() to display the line.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!