displays nothing when I plot Please help

10 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2021-2-8
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
vpos = 
11.349008767288886009586274243886
tpos
tpos = 
0.49844478627922681821464009813854
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
vy = 1×50
8.0250 7.7030 7.3810 7.0590 6.7370 6.4150 6.0930 5.7710 5.4490 5.1270 4.8050 4.4830 4.1610 3.8390 3.5170 3.1950 2.8730 2.5510 2.2290 1.9070 1.5850 1.2630 0.9410 0.6190 0.2970 -0.0250 -0.3470 -0.6690 -0.9910 -1.3130
x
x = 1×50
0 0.0802 0.1605 0.2407 0.3210 0.4012 0.4815 0.5617 0.6420 0.7222 0.8025 0.8827 0.9630 1.0432 1.1235 1.2037 1.2840 1.3642 1.4445 1.5247 1.6050 1.6852 1.7655 1.8457 1.9260 2.0062 2.0865 2.1667 2.2470 2.3272
y
y = 1×50
0 0.0754 0.1476 0.2166 0.2824 0.3449 0.4042 0.4603 0.5132 0.5629 0.6093 0.6525 0.6925 0.7293 0.7629 0.7932 0.8203 0.8442 0.8649 0.8824 0.8966 0.9076 0.9154 0.9200 0.9214 0.9195 0.9144 0.9061 0.8946 0.8798
ymax= vpa(1/2 * vpos * sind(a)* tpos)
ymax = 
2.0
plot (x,y)
title Projectile Motion

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by