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 Comment

KSSV
KSSV on 2 May 2017
Edited: KSSV on 2 May 2017
You have to specify what is that wrong? You expect us to go line by line without knowing where you are wrong?

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 1 May 2017

Edited:

on 2 May 2017

Community Treasure Hunt

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

Start Hunting!