Info
此问题已关闭。 请重新打开它进行编辑或回答。
time of flight, projectile motion, while loop. simple
2 次查看(过去 30 天)
显示 更早的评论
So i need a program that tells you when a potato launcher will hit a target.... (can change this variable and still work). initial variables vx=120, vy,x,y=0 dtarg=15 delta_t=.01seconds.I've checked all the forum information and am still not able to get mine to run correctly. our inputs for (delt_x=vx*delta_t) (delta_y=vy*delta_t) (delta_vx=(-.0036)*(v^x)^2) delta_vy=-(9.8)*delta_t. Like i said we're looking for time of impact and to a set target distance(dtarg). I am not sure what I am missing to make my code work. Any help is grately appreciated.
clc;
close all;
A=-.0036
dt=0.001; %s
i=1;
x(i)=0;
y(i)=0;
t(i)=0;
g=-9.81;
vx=120
vy=0
Dtarget=15;
while x>=15
delta_vx=vx^2*A*dt;
delta_vy=g*dt;
x(i+1)=vx*dt;
y(i+1)=vy*dt;
t(i+1)=t(i)+dt;
i=i+1;
end
0 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!