Plot rotation earth in real time with MATLAB appdesigner

Hi there
I want to make a app using by app designer.
when starting app with start time and end time, app shows the Earth 3D graphics and when you click the start button then 3D Earth rotating with real time.
Could you let me know what functions needed to make it or structure of the app.
thank you.

5 commentaires

when you say real time, do you want the earth to rotate with 1 cycle per 24h? or do you just want to see it rotate after you press the button?
@Jonas I want earth to rotate with 1 cycle per 24 hr when i click the button. Moreover, rotate speed up and down should be possible but this function would be care later.
if you want just a simple representation of a rotating earth, you can just use normal figure with some uiconotrol elements. taking the earth model from https://de.mathworks.com/matlabcentral/fileexchange/13823-3d-earth-example
we can rotate it in realtime, but you would not see much. i would apply a factor of 1000 to start to see something
%% Textured 3D Earth example
%
% Ryan Gray
% 8 Sep 2004
% Revised 9 March 2006, 31 Jan 2006, 16 Oct 2013
%% Options
space_color = 'k';
npanels = 180; % Number of globe panels around the equator deg/panel = 360/npanels
alpha = 1; % globe transparency level, 1 = opaque, through 0 = invisible
%GMST0 = []; % Don't set up rotatable globe (ECEF)
GMST0 = 4.89496121282306; % Set up a rotatable globe at J2000.0
% Earth texture image
% Anything imread() will handle, but needs to be a 2:1 unprojected globe
% image.
image_file = 'http://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Land_ocean_ice_2048.jpg/1024px-Land_ocean_ice_2048.jpg';
% Mean spherical earth
erad = 6371008.7714; % equatorial radius (meters)
prad = 6371008.7714; % polar radius (meters)
erot = 7.2921158553e-5; % earth rotation rate (radians/sec)
%% Create figure
figure('Color', space_color);
hold on;
% Turn off the normal axes
set(gca, 'NextPlot','add', 'Visible','off');
axis equal;
axis auto;
% Set initial view
view(0,30);
axis vis3d;
%% Create wireframe globe
% Create a 3D meshgrid of the sphere points using the ellipsoid function
[x, y, z] = ellipsoid(0, 0, 0, erad, erad, prad, npanels);
globe = surf(x, y, -z, 'FaceColor', 'none', 'EdgeColor', 0.5*[1 1 1]);
if ~isempty(GMST0)
hgx = hgtransform;
set(hgx,'Matrix', makehgtform('zrotate',GMST0));
set(globe,'Parent',hgx);
end
%% Texturemap the globe
% Load Earth image for texture map
cdata = imread(image_file);
% Set image as color data (cdata) property, and set face color to indicate
% a texturemap, which Matlab expects to be in cdata. Turn off the mesh edges.
set(globe, 'FaceColor', 'texturemap', 'CData', cdata, 'FaceAlpha', alpha, 'EdgeColor', 'none');
%%%%%%%%%%%%%%%%%%%%
% here the animation and buttons are added
speedText=uicontrol(gcf,'Style','text','String','1000','Units','normalized','Position',[0.18 0.1 0.1 0.05]);
pushbuttonMinus=uicontrol(gcf,'Style','pushbutton','String','-','Units','normalized','Position',[0.1 0.1 0.05 0.05],'Callback',@(~,~) set(speedText,'String',num2str(str2double(speedText.String)-200)));
pushbuttonPlus=uicontrol(gcf,'Style','pushbutton','String','+','Units','normalized','Position',[0.3 0.1 0.05 0.05],'Callback',@(~,~) set(speedText,'String',num2str(str2double(speedText.String)+200)));
updatesPerSecond=60;
while 1
if str2double(speedText.String)>0
degPerIteration=360/(24*60*60)/updatesPerSecond*str2double(speedText.String);
rotate(globe,[0 90],degPerIteration);
drawnow limitrate;
pause(1/updatesPerSecond);
end
end
@Jonas Thank you for your great help! Base on this I will add shadow side of the Earth.
also have a look into file exchange, there are very detailed versions of earth models, e.g. earth at night, with and without clouds etc

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Earth and Planetary Science dans Centre d'aide et File Exchange

Commenté :

le 27 Mai 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by