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 件のコメント

KSSV
KSSV 2017 年 5 月 2 日
編集済み: KSSV 2017 年 5 月 2 日
You have to specify what is that wrong? You expect us to go line by line without knowing where you are wrong?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

タグ

質問済み:

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