how to animate two plots at the same time?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
KSSV
le 2 Mar 2021
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Animation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!