Filter löschen
Filter löschen

Plot will not graph lines

1 Ansicht (letzte 30 Tage)
Jomarck
Jomarck am 5 Okt. 2022
Beantwortet: Star Strider am 5 Okt. 2022
I've been trying to figure out why there are no lines being plotted down here. There should be three lines of trajectory.
g = 9.81
vo = 25
y = 3.5
trajectory1 = 30
d1 = vo*cosd(trajectory1)/g*(vo*sind(trajectory1)+sqrt((vo*sind(trajectory1))^2+2*g*y))
x1 = linspace(0,d1,200)
yplot1 = x1.*tand(trajectory1)-(0.5*x1.*x1*g)/((vo.*cosd(trajectory1)).^2)+y
y1 = transpose(yplot1)
trajectory2 = 45
d2 = vo*cosd(trajectory2)/g*(vo*sind(trajectory2)+sqrt((vo*sind(trajectory2))^2+2*g*y))
x2 = linspace(0,d2,200)
yplot2 = x2.*tand(trajectory2)-(0.5*x2.*x2*g)/((vo.*cosd(trajectory2)).^2)+y
y2 = transpose(yplot2)
trajectory3 = 60
d3 = vo*cosd(trajectory3)/g*(vo*sind(trajectory3)+sqrt((vo*sind(trajectory3))^2+2*g*y))
x3 = linspace(0,d3,200)
yplot3 = x3.*tand(trajectory3)-(0.5*x3.*x3*g)/((vo.*cosd(trajectory3)).^2)+y
y3 = transpose(yplot3)
hold on
plot(d1, y1)
plot(d2, y2)
plot(d3, y3)
title('Projecticle Trajectory Graph')
xlabel('Horizontal distance')
ylabel('Vertical distance')
grid on
legend('T1','T2','T3')
hold off

Antworten (1)

Star Strider
Star Strider am 5 Okt. 2022
The ‘d’ values are all scalars.
Perhaps plooting the ‘y’ values as a function of their associated ‘x’ values —
g = 9.81;
vo = 25;
y = 3.5;
trajectory1 = 30;
d1 = vo*cosd(trajectory1)./g*(vo*sind(trajectory1)+sqrt((vo*sind(trajectory1))^2+2*g*y));
x1 = linspace(0,d1,200)
x1 = 1×200
0 0.3050 0.6099 0.9149 1.2198 1.5248 1.8297 2.1347 2.4397 2.7446 3.0496 3.3545 3.6595 3.9644 4.2694 4.5744 4.8793 5.1843 5.4892 5.7942 6.0991 6.4041 6.7091 7.0140 7.3190 7.6239 7.9289 8.2338 8.5388 8.8438
yplot1 = x1.*tand(trajectory1)-(0.5*x1.*x1*g)/((vo.*cosd(trajectory1)).^2)+y
yplot1 = 1×200
3.5000 3.6751 3.8482 4.0194 4.1887 4.3560 4.5214 4.6848 4.8463 5.0058 5.1634 5.3190 5.4727 5.6244 5.7742 5.9221 6.0680 6.2119 6.3539 6.4940 6.6321 6.7683 6.9025 7.0348 7.1651 7.2935 7.4199 7.5444 7.6669 7.7875
y1 = transpose(yplot1)
y1 = 200×1
3.5000 3.6751 3.8482 4.0194 4.1887 4.3560 4.5214 4.6848 4.8463 5.0058
trajectory2 = 45;
d2 = vo*cosd(trajectory2)/g*(vo*sind(trajectory2)+sqrt((vo*sind(trajectory2))^2+2*g*y));
x2 = linspace(0,d2,200)
x2 = 1×200
0 0.3369 0.6737 1.0106 1.3475 1.6843 2.0212 2.3581 2.6949 3.0318 3.3687 3.7056 4.0424 4.3793 4.7162 5.0530 5.3899 5.7268 6.0636 6.4005 6.7374 7.0742 7.4111 7.7480 8.0848 8.4217 8.7586 9.0954 9.4323 9.7692
yplot2 = x2.*tand(trajectory2)-(0.5*x2.*x2*g)/((vo.*cosd(trajectory2)).^2)+y
yplot2 = 1×200
3.5000 3.8351 4.1666 4.4946 4.8190 5.1398 5.4571 5.7708 6.0810 6.3875 6.6906 6.9900 7.2859 7.5783 7.8670 8.1523 8.4339 8.7120 8.9865 9.2575 9.5249 9.7887 10.0490 10.3057 10.5589 10.8085 11.0545 11.2970 11.5359 11.7712
y2 = transpose(yplot2)
y2 = 200×1
3.5000 3.8351 4.1666 4.4946 4.8190 5.1398 5.4571 5.7708 6.0810 6.3875
trajectory3 = 60;
d3 = vo*cosd(trajectory3)/g*(vo*sind(trajectory3)+sqrt((vo*sind(trajectory3))^2+2*g*y));
x3 = linspace(0,d3,200)
x3 = 1×200
0 0.2871 0.5741 0.8612 1.1483 1.4353 1.7224 2.0095 2.2965 2.5836 2.8707 3.1578 3.4448 3.7319 4.0190 4.3060 4.5931 4.8802 5.1672 5.4543 5.7414 6.0284 6.3155 6.6026 6.8896 7.1767 7.4638 7.7508 8.0379 8.3250
yplot3 = x3.*tand(trajectory3)-(0.5*x3.*x3*g)/((vo.*cosd(trajectory3)).^2)+y
yplot3 = 1×200
3.5000 3.9946 4.4841 4.9684 5.4475 5.9214 6.3902 6.8538 7.3122 7.7654 8.2135 8.6564 9.0941 9.5266 9.9540 10.3762 10.7932 11.2051 11.6117 12.0132 12.4096 12.8007 13.1867 13.5675 13.9431 14.3136 14.6789 15.0390 15.3939 15.7437
y3 = transpose(yplot3)
y3 = 200×1
3.5000 3.9946 4.4841 4.9684 5.4475 5.9214 6.3902 6.8538 7.3122 7.7654
hold on
plot(x1, y1)
plot(x2, y2)
plot(x3, y3)
title('Projecticle Trajectory Graph')
xlabel('Horizontal distance')
ylabel('Vertical distance')
grid on
legend('T1','T2','T3')
hold off
.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by