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

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?

update

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.

4 Comments

Sarah on 30 Oct 2011

check above for my commentary to your comment

proecsm on 31 Oct 2011

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

http://en.wikipedia.org/wiki/Witch_of_Agnesi

Sarah 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.

Sarah

Products

No products are associated with this question.

1 Answer

Answer by Fangjun Jiang on 30 Oct 2011

Something like this:

%%
delta_t=2*pi/100;
t=0:delta_t:2*pi;
y=sin(t);
figure(1);grid on;
plot(t,y,'r*');hold on;
dt=gradient(t)/delta_t;
dy=gradient(y)/delta_t;
quiver(t,y,dt,dy);
grid on;

0 Comments

Fangjun Jiang

Contact us