How can I sepearte these two spehrical Objects - Earth and Moon - to get one Moon and one Earth? So far I get two Moon's or either two Earth
3 ビュー (過去 30 日間)
古いコメントを表示
I tried to plot the Earth and the Moon, but I failed. Each sphere has his own Topography and here is the problem. When I run the Project the two sphere's have the topography of the Moon. How can i separate these two functions to get a sphere with the look of the Earth and the other sphere as the moon?
clear
clc
close all
%%create sphere
[X,Y,Z] = sphere;
surf(X,Y,Z)
%% combines Earth topography and sphere
%earth gets a jpg file to get the look of the earth
earth = imread('http://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Land_ocean_ice_2048.jpg/1024px-Land_ocean_ice_2048.jpg');
h2 = findobj('Type','surface');
set(h2,'CData',earth,'FaceColor','texture','edgecolor','none')
axis equal
%% second sphere
hold on
r = 7,22;
X2 = X * r;
Y2 = Y * r;
Z2 = Z * r;
surf(X2+15,Y2-15,-Z2)
%% combines the second sphere with Moon topography
moon = imread('https://upload.wikimedia.org/wikipedia/commons/b/b6/Moon_Map.jpg')
h = findobj('Type','surface');
set(h,'CData',moon,'FaceColor','texturemap','edgecolor','none')
axis equal
%%Earth and Moon spins
El = 24;
for Az = 0:360
view(Az,El)
pause(0.01)
end
0 件のコメント
採用された回答
Prudhvi Peddagoni
2020 年 12 月 29 日
Hi,
When you are executing the below line, It is returning both the Earth's surface plot and Moon's surface plot. So you are editing both surface plots when you edit the object h.
h = findobj('Type','surface');
set(h,'CData',moon,'FaceColor','texturemap','edgecolor','none')
Instead of using find function, you can directly store the output of surf function as h2 and h variables in this case.
h2 = surf(X,Y,Z)
h = surf(X2+15,Y2-15,-Z2)
Hope this helps.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Earth and Planetary Science についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!