How do I plot an animated vertical line?
이전 댓글 표시
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
DERYA DILMEN
2021년 2월 18일
Check out this answer in mathworks :
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!