Define tangent line along each boundary points of a curve
1 回表示 (過去 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!