tags:

views:

71

answers:

1

My question is simply...

I have the plot of one parabola. I made it using:

t = -20:0.1:20;
plot3(0,t,-t.^2);

Now i want to plot one vector with the origin in some point [x0 y0 z0] and the end in one point of the parabola. After that, i want to move the end of the vector along the line that describe the parabola with the origin always fixed.

Some suggestion?

+2  A: 

If you wan to do a simple animation:

t = -20:0.1:20; 
plot3(zeros(size(t)),t,-t.^2);
hold on
i = 1;
h = plot3([0 0],[0 t(i)],[0 -t(i)^2],'r');
for(i=2:length(t))
    set(h,'xdata',[0 0],'ydata',[0 t(i)],'zdata',[0 -t(i)^2]);
    pause(0.01);
end

This should do the trick.(assuming I understood your question correctly)

NB: in this example, [x0 y0 z0] is [0 0 0]

Hope this helps,

A.

Adrien
Thank you for the help.
vittorio
You understood perfectly the question. Now i will change the starting point of the line.
vittorio
Now i change the starting point of the line to [-1 0 -400]. Still Thank you, Vittorio
vittorio

related questions