File Exchange Pick of the Week

Our best user submissions

Earth and moon visualization 2

Posted by Doug Hull,

This week’s pick comes from two of my colleagues in the UK, Sam and Marta. This is a cool visualization of the Earth and its moon at the proper ratio, but not the proper distance apart. The code is very simple, and one thing I liked about it is how they were able to drape real satellite imagery over the spheres:


set(s,'cdata', im2double(topoud));

This is a nice technique for making visualizations more realistic and appealing.


Also, notice that they added a quick GUI button to the figure window with one command:

u=uicontrol('style', 'togglebutton', 'value', false, 'string', 'Exit');

They then wait for this button to be pressed so that they can close the window:

while ~get(u, 'value')
% camorbit(15,0)

While they are waiting for the user to click the button, they keep rotating the spheres. You can also see some commented out lines of code that are likely to be of interest to people that want to further modify the code later.

[note: Post updated April 23rd to add link to original code. Oops!]


Comments are closed.

2 CommentsOldest to Newest