displays nothing when I plot Please help
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Susan Chestnutt
le 8 Fév 2021
Commenté : Susan Chestnutt
le 8 Fév 2021
Hello all,
I have tried numerous different methods to get this to plot. It still does nothing. Please help...
If you are feeling super nice I would like it to plot x from 0 to 13
y_o = 0;
x_o = 0;
dt=.001;
t = 0:dt:1.1;
g = -32.2;
a = 45
x_t = 4
x (1) = x_o;
y(1) = y_o;
syms v t
eqn3 = v > 0;
eqn4 = t > 0;
eqn1 = x_t == v * cosd (a) *t;
eqn2 = t == (2 * v * sind(a))/g ;
eqns =[eqn1,eqn2];
sol = solve([eqns],[v,t]);
vS = vpa(sol.v)/1i;
tS = vpa(sol.t)/1i;
sol = solve([eqn3,eqn4],[v,t]);
vpos = vS(vS>=0);
tpos = tS(tS>=0);
vpos
tpos
dt=.01;
t_i = 0:dt:tpos;
y = zeros(1,length(tpos));
x = zeros(1,length(tpos));
vy = zeros(1,length(tpos));
Simulate the trajectory
vy = vpa(vpos * sind(a));
for i = 2 :length(tpos)
vy (i) = vy(i-1) + g * dt;
x (i) = x (i-1) + vpos * cosd(a) * dt;
y (i) = y(i-1) + vy(i) * dt + 1/2 * g * dt.^2;
end
vy
x
y
ymax= vpa(1/2 * vpos * sind(a)* tpos)
Plotting the balls path
plot (x,y)
title Projectile Motion
0 commentaires
Réponse acceptée
Walter Roberson
le 8 Fév 2021
y_o = 0;
x_o = 0;
dt=.001;
t = 0:dt:1.1; %NOT USED, WHY DOES THIS EXIST?
g = -32.2;
a = 45;
x_t = 4;
x (1) = x_o;
y(1) = y_o;
syms v t
eqn3 = v > 0;
eqn4 = t > 0;
eqn1 = x_t == v * cosd (a) *t;
eqn2 = t == (2 * v * sind(a))/g ;
eqns =[eqn1,eqn2];
sol = solve([eqns],[v,t]);
vS = vpa(sol.v)/1i;
tS = vpa(sol.t)/1i;
sol = solve([eqn3,eqn4],[v,t]);
vpos = vS(vS>=0);
tpos = tS(tS>=0);
vpos
tpos
dt=.01;
t_i = 0:dt:tpos;
numt = length(t_i);
y = zeros(1,numt);
x = zeros(1,numt);
vy = zeros(1,numt);
vy(1) = vpa(vpos * sind(a));
for i = 2 :numt
vy (i) = vy(i-1) + g * dt;
x (i) = x(i-1) + vpos * cosd(a) * dt;
y (i) = y(i-1) + vy(i) * dt + 1/2 * g * dt.^2;
end
vy
x
y
ymax= vpa(1/2 * vpos * sind(a)* tpos)
plot (x,y)
title Projectile Motion
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
