Create an animation to show that the ship is safe.

2 Ansichten (letzte 30 Tage)
Ntombikayise Bhengu
Ntombikayise Bhengu am 18 Okt. 2020
Kommentiert: mahesh kumar am 20 Okt. 2020
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); % initial flat triangle
hold off
for j = 1:length(theta)-10
xt(2) = xc(j); % determine new vertex value
yt(2) = yc(j);
t.XData = xt; % update data properties
t.YData = yt;
drawnow limitrate % display updates
  12 Kommentare
Ntombikayise Bhengu
Ntombikayise Bhengu am 19 Okt. 2020
Thank you so much. Yes this also helps a lot.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by