This is a simple solar system simulation using animation plot. The orbit of planet is generate using a function called elips.
Muhammad Raihan Ekaputra Idrisatria (2021). Simple Solar System Simulation (https://www.mathworks.com/matlabcentral/fileexchange/82214-simple-solar-system-simulation), MATLAB Central File Exchange. Retrieved .
As a general tip for animations, you only need to specify "hold on" once, and hold off at the end. Ideally do this outside the loop, so you can initially define the variables for each plot, and then just update the plot data instead of deleting and remaking the variable repeatedly.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!