How to draw tangent line in a curve?

3 views (last 30 days)
Gregorio Stiuso
Gregorio Stiuso on 18 Aug 2016
Edited: Thorsten on 19 Aug 2016
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
Gregorio Stiuso
Gregorio Stiuso on 19 Aug 2016
Yes, i need to have a tangent line that cross the origin.
Thorsten
Thorsten on 19 Aug 2016
Edited: Thorsten on 19 Aug 2016
That's not a tangent. Please see my updated answer below of how to do it.

Sign in to comment.

Answers (1)

Thorsten
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)])

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!