An enemy submarine determined to sink your ship is sitting, torpedoes armed, exactly halfway between you and your home port. The submarine submerges to some fixed depth, and your ship now has no further information about its position. The enemy sub has to be directly underneath your ship to sink it — but the sub can track your moves with precision and respond efficiently. If your ship is fast enough, though, you will be able to set a wide course around the sub and reach port safely.
How much faster than the sub does your ship have to be to guarantee you can avoid the sub and get home?
I am trying to create ananimation for this . I am struggling. This is what I tried.
Couldyou please help me out.
theta = linspace(-pi,pi);
xc = cos(theta);
yc = -sin(theta);
plot(xc,yc);
axis equal
xt = [1 0.5 -1];
yt = [0 -0.4 0];
hold on
t = area(xt,yt);
hold off
for j = 1:length(theta)-10
xt(2) = xc(j);
yt(2) = yc(j);
t.XData = xt;
t.YData = yt;
drawnow limitrate
12 Comments
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1067918
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1067918
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068513
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068513
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068638
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068638
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068708
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068708
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068843
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068843
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068848
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068848
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068868
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068868
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068873
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1068873
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1069278
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1069278
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1069323
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1069323
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1069473
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1069473
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1074338
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/617788-create-an-animation-to-show-that-the-ship-is-safe#comment_1074338
Sign in to comment.