필터 지우기
필터 지우기

How to start two plots with different origins.

조회 수: 1 (최근 30일)
Peter Denardo
Peter Denardo 2021년 11월 29일
댓글: Peter Denardo 2021년 11월 29일
Working on a problem where we have to plot the trajectory of two projectiles that intercept each other at a given point, and start at two different points on the X Axis. My code has both projectiles starting from 0 but A should start at zero and go in the positive x direction and B should start at 30,000 meters roughly and go in the -x direction. Not sure how to code B so it starts at the 30,000 meter point and goes in the -x direction. I hope that makes sense. Thank you

채택된 답변

Chunru
Chunru 2021년 11월 29일
p1 = [0 0]; % inital position for object 1
p2 = [2000 0];
v1 = [150 20]; % initial velocity for object 1
v2 = [-80 30]; % negative velocity along x-axis
g = 9.8;
t = (0:.1:10)';
p1_t = p1 + t*v1 + .5*t.^2*[0 -g];
p2_t = p2 + t*v2 + .5*t.^2*[0 -g];
plot(p1_t(:,1), p1_t(:, 2), 'r', p2_t(:,1), p2_t(:, 2), 'b')
yline(0)
  댓글 수: 1
Peter Denardo
Peter Denardo 2021년 11월 29일
Follow up question. For the velocity, you put [150 20]. What is the 20 in this case?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Physics에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by