MATLAB Answers

How do I nicely represent the final answer?

3 views (last 30 days)
The Merchant
The Merchant on 28 Oct 2019
Commented: Adam Danz on 15 Dec 2019
Problem: On a flat field a canon ball with mass m is fired under an angle θ with an initial velocity of v0. Example 1.8 showed that the horizontal distance is R = v0^2 / g * sin 2θ. So the optimal angle is equal to π/4: then R = v0^2 /g. Solve the same problem in case m = 1 kg, v0 = 10 m/s, g = 9.81 m/s^2, but now including a friction force equal to: Ð→ F w = −γÐ→vÐ→v = −γvÐ→v , γ = 0.1. Find λ in θ = λπ/4 for which the distance is maximal. For every correct digit in the value of λ you score 0.1 point with a maximum of 0.5 in total. The value of λ starts with 0, for you to find p1, p2, p3, p4, p5 in λ = 0.p1p2p3p4p5, with every 0 ≤ pk ≤ 9.
My code:
v0 = 10
gamma = 0.1
for k=1:101
theta = 0.8444 * pi/4 + (k-51)*0.0001;
dt = 0.0000001;
x = 0;
y = 0;
vx = v0 * cos(theta);
vy = v0 * sin(theta);
x = x + dt * vx;
y = y + dt * vy;
while (y>0)
v = sqrt(vx*vx+vy*vy);
vx = vx - dt * gamma * vx;
vy = vy - dt * 9.81 - dt * gamma * vx;
x = x + dt * vx;
y = y + dt * vy;
end;
t(k) = theta
a(k) = x
end;
plot(a)
[vv, jv] = max(a)
t(jv) / (pi/4)

  8 Comments

Show 5 older comments
The Merchant
The Merchant on 28 Oct 2019
how would i extract teh value tho
Bob Nbob
Bob Nbob on 28 Oct 2019
Make a variable for it. I can't really do that for you because I don't really know what lambda represents for your code. I assume it's an angle, because you have theta and are using cos and sin, but that's about all I know.
Adam Danz
Adam Danz on 15 Dec 2019
Original question by OP in case it is deleted (this user has deleted many questions after being answered).
------------------------------------------------------------------
Problem: On a flat field a canon ball with mass m is fired under an angle θ with an initial velocity of v0. Example 1.8 showed that the horizontal distance is R = v0^2 / g * sin 2θ. So the optimal angle is equal to π/4: then R = v0^2 /g. Solve the same problem in case m = 1 kg, v0 = 10 m/s, g = 9.81 m/s^2, but now including a friction force equal to: Ð→ F w = −γÐ→vÐ→v = −γvÐ→v , γ = 0.1. Find λ in θ = λπ/4 for which the distance is maximal. For every correct digit in the value of λ you score 0.1 point with a maximum of 0.5 in total. The value of λ starts with 0, for you to find p1, p2, p3, p4, p5 in λ = 0.p1p2p3p4p5, with every 0 ≤ pk ≤ 9.
My code:
v0 = 10
gamma = 0.1
for k=1:101
theta = 0.8444 * pi/4 + (k-51)*0.0001;
dt = 0.0000001;
x = 0;
y = 0;
vx = v0 * cos(theta);
vy = v0 * sin(theta);
x = x + dt * vx;
y = y + dt * vy;
while (y>0)
v = sqrt(vx*vx+vy*vy);
vx = vx - dt * gamma * vx;
vy = vy - dt * 9.81 - dt * gamma * vx;
x = x + dt * vx;
y = y + dt * vy;
end;
t(k) = theta
a(k) = x
end;
plot(a)
[vv, jv] = max(a)
t(jv) / (pi/4)

Sign in to comment.

Answers (0)

Sign in to answer this question.


Translated by