Define tangent line along each boundary points of a curve
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 2 Okt. 2014
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 Kommentare
Siehe auch
Kategorien
Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!