MATLAB Answers


Finding the tangent line of a curve at a point

Asked by Sarah
on 29 Oct 2011

Howdy, I need help with this matlab related problem.

I have the equation of a curve and I need to find the tangent line at a given point. What should I be typing to make this happen?

I figured out how to get the derivative of the curve, but I have no idea how to make matlab run the x value of the given point to give me the slope (m) of the tangent line and plug that into the equation y-y_1=m(x-x_1).

I also need to plot the tangent line with the original curve. Do I just use plot(x,y)? Please help me, I have no idea how to type programming properly.

I also need to make the given point show up as an open circle on the graph. How do I do this?


It is a homework question, but I wanted to be a bit vague so I could get guided into solving it on my own, but after spending two hours on it, I'm not getting anywhere closer to solving it.

The curve is a witch of Agnesi curve and the point is directly on it.

The open circle is for the graph, it wants the point of tangency to show as an open circle.

If anyone can give me step by step instructions on how to do it, I'd be wonderfully happy, unfortunately, I don't understand any computer language, so if you can explain in words too, that would be great.

Update 2

The curve and its derivative need to be graphed on the same graph.


on 30 Oct 2011

check above for my commentary to your comment

on 31 Oct 2011

do you need to create something like the 2nd figure on wikipedia?

on 31 Oct 2011

honestly, I'm not sure, I have to graph the curve and then its derivative on the same graph. I honestly have no idea what that will end up looking like.


No products are associated with this question.

1 Answer

Answer by Fangjun Jiang
on 30 Oct 2011

Something like this:

figure(1);grid on;
plot(t,y,'r*');hold on;
grid on;


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!