我如何使用MATLAB绘制3D向量并将其沿抛物线移动? [英] How i can draw a 3D vector with MATLAB and move it along a parabola?

查看:166
本文介绍了我如何使用MATLAB绘制3D向量并将其沿抛物线移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单...

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.

一些建议?

推荐答案

如果您想做一个简单的动画:

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:在此示例中,[x0 y0 z0][0 0 0]

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

希望这会有所帮助,

A.

这篇关于我如何使用MATLAB绘制3D向量并将其沿抛物线移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆