How do I plot an animated vertical line?
Afficher commentaires plus anciens
I want to graph the motion of a diver swimming straight downwards to the sea floor at an x position of 20,000 feet from the origin, touching it the sea floor, then immediatelely ascending directly upward.
In my case, the x-axis represents horizontal distance [0, 20000] and the y-axis is depth [0, -1000]. I want use an overlay plot where both the shark's and diver's motion are animated simultaneously. I have approached it from many directions but have not been able to animate the diver's motion.
What command should I use to illustrate the diver while the shark is swimming towards his boat at the surface?
clc, clear
%Here is the motion of the shark, swimming horizontally towards the diver's boat which is 20k feet away.
x1 = [0:1:20000];
y1 = 0*x1+0;
ax=axes;
title('Shark Motion and Diver Motion')
xlabel('Depth (Feet)')
ylabel('Horizontal Position (Feet)')
grid on
set(ax,'xlim',[0 20000],'ylim',[-1000 0]);
hold (ax);
comet(x1,y1);
%Here is the motion of the diver, swimming from the surface of the water
%straight down 1000 feet to the sea floor, then immediately swimming updard at the
%same speed.
x2 = [0:1:20000]
y2 = 0*x1+0;
set(ax,'xlim',[0 20000],'ylim',[0 -1000]);
comet(x2,y2);
%What command should I use to animate the diver's vertical motion as the
%shark approaches? I cannot get 'comet' to work.
1 commentaire
DERYA DILMEN
le 18 Fév 2021
Check out this answer in mathworks :
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!