How to draw tangent line in a curve?
3 views (last 30 days)
Show older comments
I want to draw tangent line in a curve. I know that the line must cross axes's origin, how i can do it?? I have thought to calculate derivative with command diff(y) and define the passage from point (0,0), but i don't know to do this. Thanks
This is the curve

3 Comments
Answers (1)
Thorsten
on 18 Aug 2016
Edited: Thorsten
on 19 Aug 2016
You can compute the slope with diff. Next you have to compute the y-values for x = 0 and x = 1 and plot the line. This link gives the formula:
If you want to draw a line from 0,0 through x1, x2 to the right y-axis, use
line([0 max(xlim)], [0, y1/x1*max(xlim)])
0 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!