How to draw tangent line at specified points in a curve
    16 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I am having a an array of points x,y and respective angles at those specified points. I want to plot a tangent line at those points, i am unable to figure out how to proceed.
As shown in command window 1st column contains x points , 2nd column contains y points and 3rd column the respective tangent angle. Figure 1 is plot between x and y points. Thanking you.
Regards,
Mrinal
1 comentario
  Ngo Nguyen
 el 18 de Sept. de 2013
				
      Editada: Ngo Nguyen
 el 18 de Sept. de 2013
  
			If you have the coordinates M(x,y) , so you can find the slope m:
m= -(x - x0) / (y - y0) , (x0,y0) is the center of the circle
After that, you can plot the tangent line at M y = m*(x - x0) + y0 plot(x,y)
Respuestas (1)
  Image Analyst
      
      
 el 18 de Sept. de 2013
        
      Editada: Image Analyst
      
      
 el 18 de Sept. de 2013
  
      You have to figure out the slope at each point, then decide where the endpoints of the tangent line should be, then call line([x1, x2], [y1, y2], 'Color', 'b'). As a rough guess you can probably just say the slope at xn,yn is
slope = (y(n+1)-y(n-1)) / (x(n+1) - x(n-1));
or just get the slope from the tangent angle that you already have. Then the formula for the line is (from high school algebra)
y = slope * (x - x(n)) + y(n);
You just need to figure out how far away from x(n) do you want your endpoints of your tangent line segment. I believe you can just use xLeft = min(x) and xRight = max(x) if you just want the line to go everywhere and not see the endpoints lie inside the plot.
1 comentario
Ver también
Categorías
				Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

