Define tangent line along each boundary points of a curve

6 visualizaciones (últimos 30 días)
Kyle
Kyle el 2 de Oct. de 2014
Respondida: Image Analyst el 2 de Oct. de 2014
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.

Respuestas (1)

Image Analyst
Image Analyst el 2 de Oct. de 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.

Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by