2 views (last 30 days)

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 answer this question.

Opportunities for recent engineering grads.

Apply Today
## 8 Comments

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760743

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760743

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760747

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760747

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760753

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760753

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760756

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760756

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760758

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760758

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760771

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760771

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760773

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_760773

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_778139

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/487805-how-do-i-nicely-represent-the-final-answer#comment_778139

Sign in to comment.