Plot will not graph lines
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Star Strider
2022년 10월 5일
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)
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(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
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!