Help plotting a projectile motion graph
Afficher commentaires plus anciens
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 commentaire
Réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!