필터 지우기
필터 지우기

Projectile Motion when y0 does not equal 0

조회 수: 1 (최근 30일)
Aidan
Aidan 2023년 3월 10일
답변: Voss 2023년 3월 10일
For my dynamics class is was given an example command to plot the motion of a projectile;
clear all
close all
clc
g= -9.81; % gravitational acceleration
angle= 45 *pi/180 ; % angle in radian
v0= 2; % initial speed in m/s
y0=0;
x0=0;
v0y= v0* sin(angle); % vertical initial velocity
v0x= v0* cos(angle); % horz. initial velocity
tf= v0y /(-0.5*g ); % simulate until final time = tf second
t=[0:0.001:tf]; %define time grid for simulation
n=length(t); % number of element in vector t
for i=1:1:n
y(i)=y0+(v0y)*t(i)+0.5*g*(t(i))^2; % calculate vertical position at time t
x(i)=x0+(v0x)*t(i); % calculate horizontal position at time t
end
plot(x,y)
The problem is that I need to plot the motion of a projectile with a v0 of 150 and the y0 is eqaul to 150. I am able to plug all the correct information in and get it to plot the top half of the motion (150 up and back down to 150) but it wont plot the motion below 150 back down to 0 and I am wondering how I should get it to where it will. Any suggetions or ideas???
  댓글 수: 1
Aidan
Aidan 2023년 3월 10일
I should also add that the angle of the motion is based off a 3-4-5 triangle and the launch angle is 36.87 degrees

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

답변 (2개)

Torsten
Torsten 2023년 3월 10일
이동: Torsten 2023년 3월 10일
Solve y(t) = 0 for t and you'll find tf, the time when the projectile hits the ground.

Voss
Voss 2023년 3월 10일
clear all
close all
clc
g= -9.81; % gravitational acceleration
angle= 45 *pi/180 ; % angle in radian
% v0=2; % initial speed in m/s
v0=150; % initial speed in m/s
y0=150;
x0=0;
v0y= v0* sin(angle); % vertical initial velocity
v0x= v0* cos(angle); % horz. initial velocity
% tf= v0y /(-0.5*g ); % simulate until final time = tf second
% equation for y(t): y(t) = y0 + v0y*t + 0.5*g*t^2
% you want to find the t where y(t) = 0, so call it tf and solve:
% y(tf) = y0 + v0y*tf + 0.5*g*tf^2 = 0
% for instance by applying the quadratic formula (and choose the
% "-" solution because the "+" solution gives a tf < 0):
tf = (-v0y-sqrt(v0y^2-4*0.5*g*y0))/(2*0.5*g)
tf = 22.9562
t=0:0.001:tf; %define time grid for simulation
n=length(t); % number of element in vector t
for i=1:1:n
y(i)=y0+v0y*t(i)+0.5*g*t(i)^2; % calculate vertical position at time t
x(i)=x0+v0x*t(i); % calculate horizontal position at time t
end
plot(x,y)

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by