Help plotting a projectile motion graph

Hello, I'm trying to plot a projectile motion graph using "projectile" and "trajectory", but it seems something wrong. Could anyone please help me?
:
function [x,y,t]=trajectory(T,angle,numpts)
g=9.81;
vx=sqrt(T*3.925/0.32)*0.8*cos(angle);
vy=sqrt(T*3.925/0.32)*0.8*sin(angle);
tg=2*vy*(-1)/g;
t=linspace(0,tg,numpts);
y=vy*t-.5*g*t.^2;
x=vx*t;
figure
plot(x,y)
xlabel('x (ft)');
ylabel('y (ft)');
title('Projectile Trajectory');
axis equal
projectile:
T=input('What is the applied torque (Nm):');
angle=input('What is angle with the hoeizontal axis (rad):');
numpts=input('How many points to evaluate (I suggest 50):');
[x,y,t]=trajectory(T,angle,numpts);
figure
for n=1:length(x)
plot(x(n),y(n),'ro');
axis equal;
axis([0,max(x),0,max(y)+10]);
xlabel('x (m)');
ylabel('y (m)');
title('Projectile Trajectory');
M(n)=getframe;
end
numtimes=3;
fps=10;
movie(M,numtimes,fps)

1 个评论

You have to specify what is that wrong? You expect us to go line by line without knowing where you are wrong?

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

标签

提问:

2017-5-1

编辑:

2017-5-2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by