how to animate two plots at the same time?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi everyone!
recently I've been making an orbit propagator where I plot an orbit around the Earth by plotting 2-body problem using ode45 and animate the orbit around the Earth.. but what happens is the rotation of Earth will be animated first and then the animation of the orbit begins after the Earth stops... is there any way I can make both happen at the same time?
the code:
Map = imread('earthmap.jpg');
Re = 6378; %km
[X, Y, Z]= sphere
Earth = surf(Re*X, Re*Y, -Re*Z)
set(Earth,'FaceColor','texturemap','Cdata',Map,'EdgeColor','none')
set(gcf,'Color','k')
set (gca,'Color','k')
axis equal
rotE = 360/24; %deg per hour
%Earth rotating around Z axis.
Ndays = Period/86400; %number of hours
tr = Ndays*24; %one day
for ir = 1:1:tr+1 %since time starts from 1 not 0
rotate(Earth,[0 0 1],rotE);
Anim = getframe(gca);
end
hold on
comet3(xv,yv,zv) %xv yv zv are the values I get from solving the 2-body problem which I didn't include here
댓글 수: 0
채택된 답변
KSSV
2021년 3월 2일
Put this line:
comet3(xv,yv,zv) %xv yv zv are the values I get from solving the 2-body problem which I didn't include here
into a loop as shown below:
n = length(xv) ;
for i = 1:n
plot3(xv(1:i),yv(1:i),zv(1:i)) ;
drawnow
end
If you are looking to inclide comet along with another animation.
댓글 수: 4
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!