我想绘制不同角度的曲线
v=10;
teta=20; % angle of the projectile motion
vx=v*cos(teta); % velocity in x axis
vy=v*sin(teta); % velocity in y axis
x=0:20;
y=zeros(size(x));
y=vy.*(x./vx)-(0.5*9.81*(x./vx).^2); % here I calculate the height of the ball in y axis
plot(x,y)
set(gca,'ylim',[0,5])
如何在相同的绘图中每次更改theta以绘制20度,40度和60度的theta?
谢谢
有几种实现您所需要的方法。我在下面写下了其中之一:
代码如下:
v=10;
teta=[20 40 60]; % angle of the projectile motion
vx=v*cos(pi*teta/180); % velocity in x axis
vy=v*sin(pi*teta/180); % velocity in y axis
x=0:20;
y=zeros(size(x));
for i=1:length(vx)
y(i,:)=vy(i).*(x./vx(i))-(0.5*9.81*(x./vx(i)).^2); % here I calculate the height of the ball in y axis
end
plot(x,y)
set(gca,'ylim',[0,5])
生成如下图所示:3个theta值的matlab图
对于您而言,这是一个非常基本的解决方案。
希望对您有所帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句