How to calculate the jumper's final distance on this problem?

조회 수: 1 (최근 30일)
Zifeng Qiu
Zifeng Qiu 2020년 7월 12일
댓글: Zifeng Qiu 2020년 7월 12일
This is a Matlab Grader problem for calculating the jumper's final distance with given conditions. I wrote the code down below from my lecture and I got an answer of 7.3323, but it's not correct, can anyone take a look please? Thank you.
function Dist = BJump
z0 = [0;0;pi/8;10];
dt = 0.1;
T = zeros(1,100);
T(1) = 0;
Z = zeros(4,100);
Z(:,1) = z0;
j = 1;
%for j = 1:100-1
while Z(2,j) >= 0
K1 = physics(T(j),Z(:,j));
K2 = physics(T(j) + dt/2,Z(:,j) + dt/2*K1);
K3 = physics(T(j) + dt/2,Z(:,j) + dt/2*K2);
K4 = physics(T(j) + dt,Z(:,j) + dt*K3);
Z(:,j+1) = Z(:,j) + dt/6*(K1 + 2*K2 + 2*K3 + K4);
T(j+1) = T(j) + dt;
j = j + 1;
end
plot(Z(1,1:j),Z(2,1:j))
x = Z(1,1:j);
Dist = x(end)
function dzdt=physics(t,z)
dzdt = 0*z;
dzdt(1) = z(4)*cos(z(3));
dzdt(2) = z(4)*sin(z(3));
dzdt(3) = -9.81/z(4)*cos(z(3));
D = (0.72)*(0.94)*(0.5)/2*(dzdt(1)^2 + dzdt(2)^2);
dzdt(4) = -D/80-9.81*sin(z(3));
end
end
  댓글 수: 2
Image Analyst
Image Analyst 2020년 7월 12일
Can you give us the correct answer?
Zifeng Qiu
Zifeng Qiu 2020년 7월 12일
I am sorry, I don't know what the correct answer is.

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

채택된 답변

David Hill
David Hill 2020년 7월 12일
function dist=BJump(v,theta,rho,s)
x=0;
g=9.81;
c=.72;
dt=.000001;%not sure how accurate you need
y=v*sin(theta)*dt;
while y>1e-7
dTheta=-g*cos(theta)*dt/v;
dv=(c*rho*s/2-g*sin(theta))*dt;
x=v*cos(theta)*dt+x;
v=v+dv;
theta=theta+dTheta;
y=y+v*sin(theta);
end
dist=x;
end
When I run this:
d=BJump(10,pi/8,.94,.5);%I get d=7.2748

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by