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 Commento

KSSV
KSSV il 2 Mag 2017
Modificato: KSSV il 2 Mag 2017
You have to specify what is that wrong? You expect us to go line by line without knowing where you are wrong?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Richiesto:

il 1 Mag 2017

Modificato:

il 2 Mag 2017

Community Treasure Hunt

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

Start Hunting!

Translated by